开发者

$_SERVER['document_root']?

i开发者_运维技巧s this pointing to the directory where the current file is executed?


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__);


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.


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


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.


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.


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.


'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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜