Questions about using define in include
a.php
Define (' PATH ', DirName (__file__));
Include ('./index.php ');
.
.
.
?>
b.php
Include (.. /a.php);
Echo PATH;
Where a.php and index.php are in the same folder, and b.php in A.php's parent folder.
Run the above b.php, the result is wrong, say include () function fial to open index.php, and then output path, and paht value when the absolute path of a.php.
This is what is the case, if the include function of the mechanism is to include the file does not do any processing is included in, then the value of path should be b.php absolute path, if the include function is to be included in the first processing of some functions, then include ('./ index.php '); ask what does not execute? What is the working mechanism of include and define? Seek the Master
------Optimal Solution--------------------
What does include have to do with define, is there index.php in the current directory of a.php?
2. Your constant path is defined in a.php and takes the absolute path of a.php
------Other Solutions--------------------
Use include (' index.php '); Give it a try
------Other Solutions--------------------
Reference:
use the Include (' index.php ');//
try
A.php and index.php in the same folder, and then I changed to include (' index.php ') on it, which is why?
' .' Does not mean that the current road strength, './index.php ' and ' index.php ' are not the same?
And what is the working mechanism of include?
------Other Solutions--------------------
"Summary of solutions to include paths in PHP" This blog post seems to solve my problem. The original problem appears in __file__ here, the article mentions "__file__ always equals to the real path of a PHP script regardless whether it ' s included." __file__ is always the same as the path to the file that uses it, regardless of whether the file is contained. That's why I'm talking about things. It also shows that the include path is a dangerous issue!!!!!
------Other Solutions--------------------
When you visit a.php is relative to a.php, so./index.php and index.php are all right, but if you visit b.php, it should be relative to b.php at this time, so./index.php is wrong. /index.php or index.php, that's what I understand.