Home >Backend Development >PHP Tutorial >set_include_path在win和linux下的区别_php技巧

set_include_path在win和linux下的区别_php技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-17 09:38:411091browse

刚刚调式程序,本来在服务器上好好的程序到了win下居然出错。 
后来仔细调式才发现是set_include_path的问题。 
在win下,当你要include多个路径的话,你要用“;”隔开,但在linux下就使用":"隔开的。。
Zendframe 中的include path 设置2007-06-29 11:55ZF的例子中的include_path感觉不行, 会破坏已有的设置, 所以我感觉, 要这样设置更好:

//Include Path setting
set_include_path(get_include_path() . PATH_SEPARATOR . __APP_ROOT_PATH__ . 'Library' . DIRECTORY_SEPARATOR . 'ZF' . DIRECTORY_SEPARATOR);

require 'Zend/Loader.php';



get_include_path()       是获得系统当前的inc_path路径. 

__APP_ROOT_PATH__      是我自己设置的一个常量,代表当前的目录.

PATH_SEPARATOR     这个可要说一下了, 因为WIN下的path是用 ; (分号) 来分割的, 但LINUX下是用 : (冒号) 来分割,所以要用这个常量来代表 分割符.

这样设置后, 在WIN和LINUX下, 都可以使用.  

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn