Heim  >  Artikel  >  Backend-Entwicklung  >  set_include_path在win和linux下的区别_PHP教程

set_include_path在win和linux下的区别_PHP教程

WBOY
WBOYOriginal
2016-07-21 15:54:19772Durchsuche

刚刚调式程序,本来在服务器上好好的程序到了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下, 都可以使用.  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318523.htmlTechArticle刚刚调式程序,本来在服务器上好好的程序到了win下居然出错。 后来仔细调式才发现是set_include_path的问题。 在win下,当你要include多个路径...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn