gpt4 book ai didi

php - CodeIgniter &get_instance() 在 php5.6 版本中不工作?

转载 作者:可可西里 更新时间:2023-11-01 01:14:11 24 4
gpt4 key购买 nike

我的 codeigniter 网站在 php5.4 版本中运行正常,但是当我将我的 php 版本升级到 php5.6.30 时,它无法正常工作。

function &get_instance()
{
return CI_Controller::get_instance();
}

以上函数位于我文件的第 233 行,它返回空值。

错误 - fatal error :在第 233 行的 Coginiter_site\system\core\CodeIgniter.php 中找不到类“CI_Controller”

我已经追踪到错误点 -system/core/common.php

下的代码
if ( ! function_exists('load_class'))
{
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
static $_classes = array();

// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}

$name = FALSE;

// Look for the class first in the local application/libraries folder
// then in the native system/libraries folder
foreach (array(APPPATH, BASEPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = $prefix.$class;

if (class_exists($name) === FALSE)
{
require($path.$directory.'/'.$class.'.php');
}

break;
}
}

// Is the request a class extension? If so we load it too
if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
{
$name = config_item('subclass_prefix').$class;

if (class_exists($name) === FALSE)
{
require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
}
}

// Did we find the class?
if ($name === FALSE)
{
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Excptions class
exit('Unable to locate the specified class: '.$class.'.php');
}

// Keep track of what we just loaded
is_loaded($class);

$_classes[$class] = new $name();
return $_classes[$class];
}
}

返回空结果这行创建一个问题 $_classes[$class] = new $name();请检查。

最佳答案

能不能请你关注第一个solution这个的?希望它能解决您的问题。

关于php - CodeIgniter &get_instance() 在 php5.6 版本中不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44241250/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com