Directory_separator is a command that displays the system separator, directory_separator is the internal constant of PHP and can be used directly without any definition or inclusion.
As we all know, under Windows the path separator is (of course/on some systems also can be normal operation), on Linux the path of the separator is/, which caused a problem, such as the development of the machine is Windows, there is a picture upload program, The upload files specified on the debug machine are saved in the directory: define (' ROOT ', DirName (__file__). Upload "), it is normal to debug locally, but when uploaded to the Linux server you will find that there are errors.
This problem is in the file separator, Windows habitually used as a file separator, but on Linux people do not know this logo, others only know/, so we will introduce the following PHP built-in variable: directory_separator.
The above wording can be rewritten as the following error-free notation:
Define (' ROOT ', DirName (__file__). Directory_separator. " Upload ");
This will ensure that there is no error.
For example Discuz inside is written like this: define (' S_root ', DirName (__file__). Directory_separator);
Back to the problem itself, Directory_separator is a PHP built-in command that returns the path separator associated with the operating system, returns on Windows, and returns on Linux or Class UNIX, which is the difference It is usually used when defining the include file path or uploading the save directory.
。
Define (' ROOT ', DirName (__file__). \upload ");
Debugging locally is normal, but it can go wrong after uploading to a Linux server. So, as the code of the rigorous writing:
Define (' ROOT ', DirName (__file__). Directory_separator. " Upload ");
Tip: You can use the function get_defined_constants () to get all the PHP constants, for example:
Print_r (Get_defined_constants ());//get_defined_constants () returns all constant arrays