: This article mainly introduces the PATH_SEPARATOR constant and set_include_path, a very useful advanced function of php. For more information about PHP tutorials, see. The index. php example of zendframework contains the following sentence:
Set_include_path ('. '. PATH_SEPARATOR. '.. /library /'. PATH_SEPARATOR. '. /application/models /'. PATH_SEPARATOR. '. /application/lib /'. PATH_SEPARATOR. get_include_path ()); I don't know what PATH_SEPARATOR is. it is actually a constant.
Echo directly knows its value. in linux, it is a ":" number, WIN is a ";" number.
Set_include_path is to set the path of the php inclusion file, which is equivalent to the environment variable of the operating system.
For the set_include_path problem, in win, if you want to include multiple paths, you must use ";" to separate them, but use ":" in linux.
Therefore, the above zf code is out of stock.
Get_include_path: get the existing environment variable
Definition and usage
The pathinfo () function returns the file path information in an array.
Syntax
pathinfo(path,options)
Parameters |
Description |
Path |
Required. Specifies the path to be checked. |
Process_sections |
Optional. Specifies the array element to be returned. The default value is all. Possible values:
- PATHINFO_DIRNAME-returns only dirname
- PATHINFO_BASENAME-only return basename
- PATHINFO_EXTENSION-returns only extension
|
Description
Pathinfo () returns an associated array containing path information.
Includes the following array elements:
- [Dirname]
- [Basename]
- [Extension]
Tips and comments
Note: if not all units are required, the pathinfo () function returns a string.
Example
Example 1
Output:
Array([dirname] => /testweb[basename] => test.txt[extension] => txt)
Example 2
Output:
test.txt
Under DIRECTORY_SEPARATOR window
Description
Path separator
Windows
\ Or/
Linux
/
Function _ autoload ($ classname ){
If (preg_match ('/\\\/', $ classname )){
$ Path = str_repace ('\', DIRECTORY_SEPARATOR, $ classname );
} Else {
$ Path = str_replace ('_', DIRECTORY_SEPARATOR, $ classname );
}
Require_once ("$ path. php ");
}
Reprinted from: http://www.cnblogs.com/jackluo/archive/2013/04/09/3010257.html
The above describes the advanced functions PATH_SEPARATOR and set_include_path, which are very useful for php. They include some content and hope to help those who are interested in PHP tutorials.