__FILE__ indicates that the absolute path of the current file includes the filename, dirname (__file__) represents the absolute path to the current file, and basename (__file__) represents the file name of the current file, DirName (__file__). " /f/". BaseName (__file__) represents the file under the F directory in the directory of the current file, which is called dirname (__file__), and require indicates that the file is included in the file.
Here is a detailed explanation: 1 The dirname (__file___) function returns the path where the script is located. For example, file b.php contains the following:
<?php
$basedir = DirName (__file__);
?>
If b.php is referenced by a.php file require or include in other directories.
The contents of the variable $basedir or the path of the folder where b.php resides.
Instead of becoming the directory where the a.php file resides.
2) dirname (__file__) typically returns the 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 in the default Web directory of the http.conf or PHP configuration development environment.
For example, Web_root is: "c:/root/www/".
The b.php file path is: "c:/root/www/b.php".
3) Using the method hint, 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.
4 contains files that are available at the previous level of the directory Include (DirName (__file__). " /.. /filename
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.