This time to everyone to bring dirname (file) use case to explain, dirname (file) Use the attention of what, the following is the actual case, together to see.
File indicates that the absolute path of the currently located document includes a file
__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/"
in PHP dirname () and __file__ is our constant, this article gives you a detailed introduction dirname () and __file__ constants in the use of some matters, a great interest of friends can enter the reference.
DirName () function
String DirName
The dirname (file_) function returns the path where the script is located.
For example, the file b.php contains the following content:
If b.php is referenced by a a.php file require or include in another directory.The contents of the variable
The path of _ file _ is the file where the current code is located.
Dirname (_ file _); the directory name at the top of the file is obtained.
Dirname (_ file _); the directory name of the file's layer is obtained.
"../" Is suitable for a simple
DirName (file) takes the absolute path to the current file, which means that the lookup speed is the fastest compared to the relative path.
PHP constant DirName (file)File: called the PHP Magic Constant, returns the full path and file name of the
__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/"
This article mainly introduces the usage of _ FILE _, dirname, and basename in PHP, and analyzes in detail the usage of _ FILE _, dirname, and basename in the form of an instance, test and compare the built-in function in WordPress
This article
1, the full name of MVC is the model View Controller, is the models-view (Controller) abbreviation, a software design paradigm, with a business logic, data, interface display separation method to organize the code, Aggregating business logic into a
This article mainly introduces the usage of _ FILE _, dirname, and basename in PHP, and analyzes in detail the usage of _ FILE _, dirname, and basename in the form of an instance, I also tested and compared the built-in functions in WordPress. For
DirName (__file__) takes the absolute path to the current file, which means that the lookup speed is the fastest compared to the relative path.
For example, the current file is placed under (d:\www\), the file name is test.php.The code for the
For example, the current file is placed under (d:\www\), the file name is test.php.
The code for the test is as follows:
Copy CodeThe code is as follows:
Echo __file__; Get the absolute address of the current file, result: D:\www\test.php
echo
The example in this paper describes the usage of __file__, dirname and basename in PHP. Share to everyone for your reference. Here's how:
__file__ the full path and file name of the currently running file in PHP, and if used in the included file,
This article describes the __file__, dirname and basename usages in PHP. Share to everyone for your reference. The specific methods are as follows:
__file__ the full path and filename of the current running file in PHP, if used in the included file,
__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/"
This article mainly introduces the usage of _ FILE _, dirname, and basename in PHP, and analyzes in detail the usage of _ FILE _, dirname, and basename in the form of an instance, I also tested and compared the built-in functions in WordPress. For
In the forum to read a lot of posts, but found that some people are not very likely to use. Think that the description is not detailed enough to achieve! I'll talk to you again. First, you create a new rss.php file and copy the following code into
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:
Echo __file__; Get the absolute address of the current file, result: D:\www\test.php
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:
Echo __file__; Get the absolute address of the current file, result: D:\www\test.php
echo dirname
This article mainly introduces the use of file, DirName and basename in PHP, and analyzes the specific usage of file, dirname and basename in the case form, and tests and compares the functions in WordPress, which need friends to refer to.
The full
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.