【发布时间】:2023-04-08 15:17:01
【问题描述】:
我的应用程序在开发环境中运行良好。将其上传到生产服务器后,出现以下错误:
解析错误:语法错误,意外的 T_FUNCTION,期望在 /home/fjamal/public_html/*/anyname/application/config/config.php 第 27 行
错误是指以下代码:
spl_autoload_register(function($class)
{
if (strpos($class, 'CI_') !== 0)
{
if (file_exists($file = APPPATH . 'core/' . $class . EXT))
{
include $file;
}
elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
{
include $file;
}
}
});
如果我将上述代码更改为旧版本:
function __autoload($class)
{
if (strpos($class, 'CI_') !== 0)
{
if (file_exists($file = APPPATH . 'core/' . $class . EXT))
{
include $file;
}
elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
{
include $file;
}
}
}
我收到以下错误:
致命错误:在中找不到类“Frontend_Controller” /home/fjamal/public_html/**/anyname/application/controllers/home.php 在第 4 行
错误解释:我的控制器从位于 Libraries 文件夹中的 Frontend_Controller 扩展而来。 Frontend_Controller 从位于 core 文件夹下的 MY_Controller 扩展而来。出于某种原因,生产环境中的所有这些问题,我都没有在我的本地主机中得到它。因此,home 是默认控制器。
这个错误会阻止应用程序运行,我根本想不通。任何帮助将不胜感激。
【问题讨论】:
-
要么告诉我们哪一行是第 27 行(并发布第 1-26 行),要么只是发布
config.php文件 - 它会将这个问题从“阅读并计算出你想要的”变成“发现致命错误”,这是一个更容易的答案:P -
您确实更改了生产配置文件中的 base_URL 对吗?你的 .htaccess 文件呢?
-
您的生产环境中运行的是哪个 PHP 版本?
-
是的,我更改了 base_url;生产服务器具有 PHP 版本 5.2.17。我的开发环境有 PHP 5.3.1
标签: php codeigniter codeigniter-2