For example, the current file is placed under (d:\www\) and the filename is test.php.
The code for the test is as follows:
Copy Code code as follows:
<?php
Echo __file__; Get the absolute address of the current file, result: D:\www\test.php
echo dirname (__file__); Gets the absolute directory where the current file is located, as a result: D:\www\
Echo dirname (DirName (__file__)); Gets the top level directory name of the current file, as a result: d:\
?>
Using method hints,
DirName (__file__) takes the absolute path of the current file, which means that the lookup speed is the fastest compared to the relative path.
If you repeat, you can elevate the directory up one level:
For example: $d = DirName (dirname (__file__));
The fact is that a directory for dirname () to do the parameters. Because DirName () returns the last directory without \ or/
So when you reuse it you can assume that dirname () treats the lowest directory as a filename. Return as usual
The parent directory of the current directory. So the repetition gets the directory of its upper level.
Contains files that get a previous level of directory
Include (DirName (__file__). ' /.. /filename.php ');
The __file__ path is the file where the current code resides
DirName (DirName (__file__)); Got a directory name on the file.
DirName (__file__): The name of the directory in which the file resides