php如何解决项目中多个自动加载冲突?
在有的框架中的自动加载机制,在发现无法加载时, 直接报错, 而没有把控制权转交给下一个自动加载方法., 如我要引入阿里云日志服务接口sdk,该sdk中自带自动加载方法,如下:

创新互联建站成立与2013年,先为盐田等服务建站,盐田等地企业,进行企业商务咨询服务。为盐田企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
4)
$classPath = array_slice($classPath, 0, 4);
$filePath = dirname(__FILE__) . '/' . implode('/', $classPath) . '.php';
if (file_exists($filePath))
require_once($filePath);
}
}
spl_autoload_register('Aliyun_Log_PHP_Client_Autoload');上面自动加载方法会与原有框架自己的加载方法冲突,解决方法如下:
4)
$classPath = array_slice($classPath, 0, 4);
unset($classPath[0]);
$filePath = dirname(__FILE__) . '/' . implode('/', $classPath) . '.php';
if (file_exists($filePath))
require_once($filePath);
}
}
);
// 如果引用本框架的其它框架已经定义了__autoload,要保持其使用
if (function_exists('__autoload')) {
spl_autoload_register('__autoload');
}
// 再将原来的自动加载函数放回去
if ($oldFunctions){
foreach ($oldFunctions as $f) {
spl_autoload_register($f);
}
}
}
# 最后调用上面方法
autoloadAdjust();以上就是php 解决项目中多个自动加载冲突问题的详细内容,更多请关注创新互联其它相关文章!
分享题目:php如何解决项目中多个自动加载冲突?
URL链接:http://www.jxjierui.cn/article/ghipih.html


咨询
建站咨询
