加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 致命错误:在joomla 3.3中找不到类’JFactory’

发布时间:2020-12-13 21:51:24 所属栏目:PHP教程 来源:网络整理
导读:3 我有一个我在我的网站上开发但没有joomla结构的表单. 在表单上,??我试图调用活动用户数据,如下所示: $user = JFactory::getUser();echo "pYour name is {$user-name},your email is {$user-email},and your username is {$user-username}/p"; 但我得到了
3
我有一个我在我的网站上开发但没有joomla结构的表单.
在表单上,??我试图调用活动用户数据,如下所示:

$user = JFactory::getUser();
echo "<p>Your name is {$user->name},your email is {$user->email},and your username is  {$user->username}</p>";

但我得到了:
致命错误:第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文件的位置.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读