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 开发者_如何学Gonot 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.
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
..
means "one directory up"; ../..
would mean "two directories up".
..
references to relative path one level up the current path.
精彩评论