Assume that the current file is stored under (d:www) and the file name is test.php.
Assume that the current file is stored under (d:www) and the file name is test.php. Copy code The code is as follows:Instructions: dirname(__FILE__) obtains the absolute path of the current file. Compared with relative paths, the search speed is the fastest. If you repeat it once, you can move the directory up a level: For example: $d = dirname(dirname(__FILE__)); In fact, you just give a directory as a parameter to dirname(). Because dirname() returns the last directory without \ or / Therefore, when reused, it can be considered that dirname() treats the lowest directory as a file name. Return as usual The upper-level directory of the current directory, so that if you repeat it, you will get its upper-level directory. Contains files from the upper-level directory: Copy code The code is as follows: include(dirname(__FILE__).’/../filename.php’); |