Php 致命错误:类';JFactory';未在joomla 3.3中找到
三, 我在我的网站上开发了一个表单,但不是joomla结构。 在表单上,我尝试调用活动用户数据,如下所示:Php 致命错误:类';JFactory';未在joomla 3.3中找到,php,joomla,Php,Joomla,三, 我在我的网站上开发了一个表单,但不是joomla结构。 在表单上,我尝试调用活动用户数据,如下所示: $user = JFactory::getUser(); echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>"; $user=JFactory::getUser(); echo“
$user = JFactory::getUser();
echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>";
$user=JFactory::getUser();
echo“您的名字是{$user->name},您的电子邮件是{$user->email},您的用户名是{$user->username}”;
但我得到了:
致命错误:在第38行的/home5/onlinepc/public_html/action/subs/custompcorder.php中找不到类“JFactory”
custompcorder.php是我创建的表单的名称,第38行是$user=JFactory::getUser();
我必须在我的文件中包含一些内容?您需要导入Joomla库才能使用它的API,如下所示:
<?php
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__) . '/../../'));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$mainframe = JFactory::getApplication('site');
?>
您可能需要更改上面代码第2行的路径,具体取决于Joomla相对于自定义PHP文件的位置。我很难包含目录路径。我的自定义php文件位于
Public/action/subs/custompcorder.php
defines.php和framework.php中:Public/includes/defines.php
和Public/includes/framework.php
我的设置每次都将我带到“Public/action/subs/includes/framework/framework”。php@user3412978-我已经更新了代码因此。现在应该可以了