function __autoload($class) {
if (strpos($class, 'CI_') !== 0) {
if (file_exists($file = APPPATH . 'core/' . $class . php)) {
include $file;
}
}
}
Run Code Online (Sandbox Code Playgroud)
不推荐使用:不推荐使用 __autoload(),使用 spl_autoload_register() 和致命错误:无法在 codeigniter 中重新声明 __autoload() 错误
要添加 spl_autoload_register() 只需将此代码替换为您的代码,尤其是在 routes.php 中
function my_autoloader($class) {
if (strpos($class, 'CI_') !== 0) {
if (file_exists($file = APPPATH . 'core/' . $class . 'php')) {
include $file;
}
}
}
spl_autoload_register('my_autoloader');
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
11670 次 |
| 最近记录: |