When you include a file with include or Requice, the file path is preceded by DirName (__file__). For example: Existing a.php, b.php, c.php, D.PHP4 files, their relationship is:
B.php (same level as root directory)
Root directory/a.php
Root directory/c.php
Root directory/dir/d.php
Now a.php to include b.php, c.php. The wording is as follows:
Include_once (DirName (__file__). " /.. /b.php "); Include_once (DirName (__file__). " /c.php "); ?> |
If you want to include d.php in c.php. The wording is as follows:
Include_once (DirName (__file__). " /dir/d.php "); ?> |
This approach is currently the most effective way to solve the problem of path dislocation.
http://www.bkjia.com/PHPjc/371464.html www.bkjia.com true http://www.bkjia.com/PHPjc/371464.html techarticle through and multiple tests, the relative paths in other Web programming languages are based on the current processing file directory, which is not the case in PHP. The relative path in PHP is the current ...