$_SERVER['document_root']?

发布于 2024-08-17 19:28:42 字数 26 浏览 2 评论 0原文

this 是否指向当前文件执行的目录?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

半葬歌 2024-08-24 19:28:42

不,它指向您的网络服务器的根目录 - 您网站的最顶层文件夹。

如果您想要当前文件的目录,请使用:

dirname(__FILE__);

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

高速公鹿 2024-08-24 19:28:42

来自 http://php.net/manual/en/reserved.variables.server .php

“DOCUMENT_ROOT”
当前脚本在其下执行的文档根目录,如服务器配置文件中所定义。

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.

浅听莫相离 2024-08-24 19:28:42

也许,取决于服务器的设置方式。更好的方法是:

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

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
不即不离 2024-08-24 19:28:42

不,不是,

DOCUMENT_ROOT 指向您的网络服务器的根目录,而PATH_INFO 则指向当前文件执行的目录。

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.

难理解 2024-08-24 19:28:42

当前脚本正在执行的文档根目录,如服务器配置文件中所定义。

顾名思义,它是根目录。

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.

望笑 2024-08-24 19:28:42

是的。它是相对于服务器根目录(而不是文档根目录)的路径,描述当前脚本的目录。它没有尾部斜杠。

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.

坐在坟头思考人生 2024-08-24 19:28:42

“DOCUMENT_ROOT”
当前脚本在其下执行的文档根目录,如服务器配置文件中所定义。

http://www.php.net/manual/en/reserved。变量.server.php

'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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文