开发者

PHP file path extra dot

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜