$_SERVER['document_root']?

安稳与你 提交于 2019-12-11 04:02:12

问题


is this pointing to the directory where the current file is executed?


回答1:


No, it points to the root of your webserver - the topmost folder of your website.

If you want the directory of the current file, use:

dirname(__FILE__);




回答2:


From http://php.net/manual/en/reserved.variables.server.php

'DOCUMENT_ROOT' The document root directory under which the current script is executing, as defined in the server's configuration file.




回答3:


Maybe, depending on how the server is set up. A much better method is:

echo dirname(__FILE__); // return the absolute file-path to where the current PHP file is



回答4:


No, it's not,

DOCUMENT_ROOT points to the root directory of your webserver, while PATH_INFO points to the directory where the current file is executed.




回答5:


The document root directory under which the current script is executing, as defined in the server's configuration file.

as the name implies it's a root directory.




回答6:


Yes it is. It's a path relative to the root of your server (not your document root) that describes the directory of the current script. It does not have a trailing slash.




回答7:


'DOCUMENT_ROOT'
The document root directory under which the current script is executing, as defined in the server's configuration file.

http://www.php.net/manual/en/reserved.variables.server.php



来源:https://stackoverflow.com/questions/2072126/serverdocument-root

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!