Home >Backend Development >PHP Tutorial >The difference between set_include_path under win and linux_PHP tutorial

The difference between set_include_path under win and linux_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:54:19844browse

I just debugged the program, and the program that was working fine on the server actually went wrong under win.
After careful debugging, I found out that it was a problem with set_include_path.
Under win, when you want to include multiple paths, you have to separate them with ";", but under Linux, use ":" to separate them. .
The include path setting in Zendframe 2007-06-29 11:55 The include_path in the ZF example does not feel good and will destroy the existing settings, so I feel that it is better to set it up like this:

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

require 'Zend/Loader.php';



get_include_path() is to get the current inc_path of the system.

__APP_ROOT_PATH__ is a constant I set myself, representing the current directory.

PATH_SEPARATOR There is a lot to say about this , because the path under WIN is separated by ; (semicolon), but under LINUX it is separated by : (colon), so this constant is used to represent the separator.

After setting like this, It can be used under both WIN and LINUX.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318523.htmlTechArticleI just adjusted the program, and the program that was working fine on the server actually went wrong under win. After careful debugging, I found out that it was a problem with set_include_path. Under win, when you want to include multiple paths...
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