__FILE__ indicates that the absolute path to the current file includes the filename, dirname (__file__) represents the absolute path of the current file, and basename (__file__) represents the file name of the current file, DirName (__file__). " /f/". BaseName (__file__) is the directory under the current file under the F directory, the file name is called dirname (__file__) files, require represents the file contained in this file.
here is an explanation:
1) The dirname (__file___) function returns the path where the script is located.
For example, the file b.php contains the following content:
$basedir = DirName (__file__);
?>
If b.php is referenced by a a.php file require or include in another directory.
The contents of the variable $basedir are also the path to the folder where the b.php resides.
Instead of becoming the directory where the a.php file resides.
2) dirname (__file__) typically returns a directory structure of the current directory of the file to the system root directory.
The current file name is not returned.
DirName (__file__) may also return one. (current directory)
[The reason is that the b.php file is under the default Web directory of the http.conf or PHP Configuration development environment.]
For example web_root: "c:/root/www/".
The b.php file path is: "c:/root/www/b.php".
3) Using the method tips,
If you repeat, you can raise the directory up one level:
For example: $d = DirName (dirname (__file__));
The fact is that a directory to dirname () to do the parameters. Because DirName () returns the final directory without \ \ or
So when you reuse it, you can think of dirname () handling the lowest-level directory as a file name. Return as usual
The parent directory of the current directory. That way, you get the top level of the directory.
4) file containing the previous level of the directory
Include (DirName (__file__). /.. /filename
http://www.bkjia.com/PHPjc/327806.html www.bkjia.com true http://www.bkjia.com/PHPjc/327806.html techarticle __file__ indicates that the absolute path of the current file includes the filename, dirname (__file__) represents the absolute path of the current file, basename (__file__) represents the file name of the current file, DirName (_ ...