The role of Directory_separator in PHP
Directory_separator is the internal constant of PHP, which is used to display the system delimiter commands without any definition or inclusion.
Under Windows, the path delimiter is \ (or, of course, on some systems), the delimiter on Linux is/, which causes a problem, such as the development machine is windows, there is a picture upload program, the debug machine on the specified upload file save directory is:
Define (ROOT, DirName (__file__). " /upload ");
Debugging on-premises is normal, but when uploading to a Linux server, you will see an error. So PHP introduced the directory_separator variable, you can rewrite the above syntax:
Define (ROOT, DirName (__file__). Directory_separator. " Upload ");
Directory_separator is a PHP built-in command that returns the path delimiter associated with the operating system, returns \ on Windows, and returns on Linux or Unix--that's the difference, This is usually used when you define a file path or upload a directory to save it.
For example:
View Plaincopy to Clipboardprint?
Const DIR_SEP = directory_separator;//Path segmentation win under Linux/
Private Function __construct ()
{
$this->_options = Array (
Template_dir = templates. Self::D ir_sep,//directory where template files are located
Cache_dir = templates. Self::D ir_sep. Cache. Self::D ir_sep,//cache file storage Directory
Auto_update = False, if the cache is regenerated when the template file changes
Cache_lifetime = 0,//Cache life cycle (minutes), 0 for permanent
suffix =. html//template file suffix
);
}
http://www.bkjia.com/PHPjc/905602.html www.bkjia.com true http://www.bkjia.com/PHPjc/905602.html techarticle PHP's role in Directory_separator directory_separator is the internal constant of PHP, which is used to display the system delimiter command, without any definition and inclusion to be used directly. Under Windows ...