PHP's built-in variable directory_separator is a command that displays the system delimiter, Directory_separator is the internal constant of PHP, and does not require any definition or inclusion to be used directly. This variable is used to solve the file delimiter, on Windows we habitually use \ as a file delimiter, but on the Linux people do not know this logo, people only know/, so we will introduce the following PHP built-in variables: directory_separator
For example:
Define (' Blogguy. Cn_root ', DirName (__file__). " /upload ");
The above definition in the Windows system debugging should be normal, but upload to the Linux server you will find error, the error appears on this file delimiter, so the above can be rewritten as the following the correct wording:
Define (' Blogguy. Cn_root ', DirName (__file__). Directory_separator. " Upload ");
This ensures that there are no errors. For example Discuz is written in this way: define (' S_root ', DirName (__file__). Directory_separator); Back to the problem itself, 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-like. This is the difference, which is usually used when defining a file path or uploading a saved directory.
Take a look at the following example:
Const DIR_SEP = directory_separator;//path split under win \ 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
);
}