Data collection and multiple tests have found that relative paths in other Web programming languages are based on the current processing file directory, not in PHP. The relative path in PHP is based on the current working directory, not on the current processing file directory, which is causing a lot of trouble during the development process.
When you include a file with include or Requice, the file path is preceded by a dirname (__file__). For example: Existing a.php, b.php, c.php, D.PHP4 files, they relate to:
B.php (same level as root directory)
Root directory/a.php
Root directory/c.php
Root directory/dir/d.php
Now include b.php, c.php in the a.php. The wording is as follows:
<?php
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:
<?php
Include_once (DirName (__file__). " /dir/d.php ");
?> This approach is currently the most effective way to solve the problem of path dislocation