PHP文件路径额外点

in a tutorial I am doing, the code below is in index.php file. Does the second "." in the file indicate that index.php is not at the root level? what would the significance be of adding extra "." in that position?

require_once("../includes/database.php");

This is a relative path to the current directory.

  • "." indicates the current directory
  • ".." indicates one level up in the directory structure

So the answer is yes, that file is not in the root level.

.. means "one directory up"; ../.. would mean "two directories up".

.. references to relative path one level up the current path.

Not necessarily. For security reasons it is recommended that your include files be placed outside the web-accessible directory (htdocs), so minimizing the possibility of someone calling the database.php directly with forged parameters.

So the directory structure should look somthing like:

user
| |
| + htdocs
|   |
|   + index.php
|
+ includes
  |
  + database.php