The new magic constant DIR in PHP5.3 we know that PHP provides a magic constant (magic constant) _ FILE __, which is used to point to the currently executed PHP script.
However, PHP does not directly provide constants in the directory where the script is located. That is to say, if we want to get the directory where the current PHP script is located, we need to use the dirname () function:
<? Php
$ Dir = dirname (_ FILE __);
?>
In PHP5.3, a new constant _ DIR __is added to point to the directory where the currently executed PHP script is located.
For example, the current php file is/www/website/index. php.
Then _ FILE _ is equal to '/www/website/index. php'
The value of _ DIR _ is equal to '/www/website'
To include files in the current file directory or subdirectory, you can directly use:
Require_once _ DIR _. '/path/to/test. inc. php';?>
This article is reprinted article ---- Original address http://blog.csdn.net/haohappy2004/article/details/2114808
Permanent Address: http://blog.it985.com/15611.html
This article is from the IT985 blog. please indicate the source and relevant links when reprinting.