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
For example, the current file is placed under (d: \ www \) and the file name is test. php.
The test code is as follows:
Copy codeThe Code is as follows: Echo _ FILE _; // obtain the absolute address of the current FILE. Result: D: \ www \ test.
PHP constant dirname (_ file _) learning PHP constant dirname (_ file __)
_ FILE _: a PHP magic constant. it returns the complete path and FILE name of the currently executed PHP script, including an absolute path.
1) the dirname (_ FILE _)
Do I need to convert the backslash into a slash when dirname (_ FILE _) is used? Define (AAA, str_replace (\, dirname (_ FILE _); include (AAA. bbbc. php); include (dirname (_ FILE __). bbbd. php); are the results the same? ------ Solution -------
In PHP, dirname (_ file _) is a very effective method to use dirname (_ FILE _) when configuring the file path, however, because the path of _ FILE _ is the complete path of the FILE where the current code is located (rather than the FILE where the
_ FILE __: a PHP magic constant. it returns the complete path and FILE name of the current PHP script, including an absolute path 1) dirname (_ FILE __) the function returns the path where the script is located.
_ FILE __: a PHP magic constant. it
PHP constant dirname (_ file __)
_ File _: a PHP magic constant. It returns the complete path and file name of the currently executed PHP script, including an absolute path.
1) The dirname (_ file _) function returns the path of the script.For
For example, the current file is placed under (d: \ www \) and the file name is test. php.The test code is as follows:Copy codeThe Code is as follows:Echo _ FILE _; // obtain the absolute address of the current FILE. Result: D: \ www \ test. phpEcho
For example, the current file is placed under (d: \ www \) and the file name is test. php.TestedCodeAs follows:
Echo _ file _; // obtain the absolute address of the current file. Result: D: \ www \ test. php
Echo dirname (_ file _); //
_ FILE __: a PHP magic constant. it returns the complete path and FILE name of the current PHP script, including an absolute path. 1) the dirname (_ FILE _) function returns the path where the script is located and updates the network, such as FILE
1. Understand OS. path. dirname (_ file __)
Obtain the path name:OS. path. dirname ()
Obtain the complete path of the directory where the file is located: OS. path. dirname (_ file __)
You can also configure settings. py in the django project as
Recently, when developing templates for wordpress, we found that path errors may occur when calling other php code snippets in the form of include ("file name. Previously, the server environment was always iis, and no similar bugs were found.
Dirname (_ file __)PHP defines a very useful constant, that is
_ File __
This internal constant is the complete path (path + file name) of the current PHP program ).
Even if this file is referenced by another file (include or require), __file _ is
For details about the difference between php getcwd and dirname (_ FILE _), getcwddirname
_ FILE _ is a magic constant used to obtain the complete path and FILE name of a FILE. If it is used in a file to be included, the file name to be included is
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
Code: test
$ A = 'dir C: '; // note: the key on the left of keyboard 1 is used to output information about drive C.Echo $;
?>
Symptom: All Chinese characters after running are garbled, but they are displayed normally in the source file.
Solution:
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
Use the YIIFramework library for development .... yii: createWebApplication ($ config); there is no runYii: import (class1, true). When storing the class1 class file path, also include this file. Note: you can also divide the configuration file into
Phpbench file _ get absolute file path usage. PHP constant dirname (_ file _) _ FILE __: it is called a PHP magic constant and returns the complete path and file name of the currently executed PHP script, including an absolute path 1) the PHP
_ FILE _: a PHP magic constant. It returns the complete path and FILE name of the currently executed PHP script, including an absolute path.1) the dirname (_ FILE _) function returns the path of the script. Update networkFor example, the document B.
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.