Under Windows, you can use "/" or "\" to represent the directory hierarchy, while Linux can only use "/", and there is no concept of a drive letter under Linux, only the "/" symbol represents a unique root directory. Therefore, using a variable to represent the directory location, with "/" the most secure, under any system is legal. But there is one problem to be aware of, is the above mentioned Windows drive letter with the Linux root problem !
For example, $path = "/dir/", which is an absolute path, under Linux it clearly represents the Dir directory under the root directory, and in Windows, it represents the Dir directory under the current drive letter! , the "current drive letter" here refers to the drive letter where the Web server is located! For example, if your Apache is on the D-plate, then $path represents d:/dir/.
In order not to confuse, it is best to use $_server[' Document_root ') plus a relative path to represent, such as: $path = "dir/", the absolute path is: $_server[' Document_root '). $path. The directory location is the Dir directory under the root of the Web directory, it is recommended to use this global variable to represent the path, not easily confused.
Also available "." Represents the relative path representation of the current directory, this "." Represents the current directory of the script file , not the location of the Web directory tree. and ".." Represents the upper-level directory. is also relative to the location of the script file.
Directory path problem with PHP