set_include_path(get_include_path() . P_S . '.' . P_S . $siteConf['baseDir']);
set_include_path(get_include_path() . P_S . '.' . P_S . $siteConf['libDir']);
set_include_path(get_include_path() . P_S . '.' . P_S . $siteConf['baseDir'] . 'app');
代码如上,P_S即PATH_SEPARATOR
问题:
为什么每个路径前都要加'.'这个呢?
我查了下手册,在评论中有这么一个,这说明加它还是有必要的,但是原因还是未知....
joel at pittet dot ca17-Nov-2010 02:46
Seems set_include_path wasn't working for me.
The problem was i didn't have .: in my include_path
Which seemed to stop the set_include_path().
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这货估计是直接 set_include_path("/some/path"); 于是在 include(当前目录下的文件) 的时候出错了。
这就类似于在linux下执行当前目录下的文件不用上 ./ 会出错一样。
如果你用了get_include_path() 去拼的话就不需要这样了。你可以把get_include_path()的值echo出来看看,里头已经包含了 "."