AI摘要
文章讨论了phpGrace工具实例化函数的一个bug,该bug导致在Linux环境下无法加载没有命名空间的工具类文件。问题出在文件路径拼接时多出了一个**/** 字符。解决方案是注释掉`className;`这一行代码。
文章讨论了phpGrace
phpGrace/phpGrace.php
//工具实例化函数( 适用于不能使用命名空间的工具类 )
function tool($args){
static $staticTools = array();
$arguments = func_get_args();
$className = array_shift($arguments);
$className = '\\'.$className;
if(empty($staticTools[$className])){
$fileUri = PG_IN.PG_TOOLS.PG_DS.$className.'.php';
if(!is_file($fileUri)){throw new pgException("类文件 {$toolName} 不存在");}
include $fileUri;
$staticTools[$className] = 1;
}
windows下正常
但在linux下,对于不能使用命名空间的工具类(如graceWeChat.php工具类),提示类文件无法加载, 文件加载路径多出一个/ 字符。
将
className;
注释后搞定。