gpt4 book ai didi

php - 点斜杠对 PHP 包含调用有什么作用?

转载 作者:IT王子 更新时间:2023-10-29 00:57:03 27 4
gpt4 key购买 nike

一个。这是做什么的?

require ("./file.php");

B.与此相比?

require ("file.php");

(它不是上一级目录..应该是)

require ("../file.php");

最佳答案

./当前 目录。它与 file.php 大致相同。 ,但在许多情况下(包括这个)它不检查 PHP 可能查找文件的任何标准位置,而是检查 当前目录。

来自 PHP documentation (注意最后一句):

Files for including are first looked for in each include_path entry relative to the current working directory, and then in the directory of current script. E.g. if your include_path is libraries, current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first looked in /www/libraries/ and then in /www/include/. If filename begins with ./ or ../, it is looked only in the current working directory.

关于php - 点斜杠对 PHP 包含调用有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/579374/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com