dot-slash对PHP做什么包括调用? [英] What does the dot-slash do to PHP include calls?
问题描述
一个。这是做什么的?
require ("./file.php");
B.与此相比?
require ("file.php");
(不 up-one-directory ..这将是)
(Its not up-one-directory.. which would be)
require ("../file.php");
推荐答案
./
是当前目录。它与 file.php
大致相同,但在很多情况下(包括这个)它不检查PHP可能寻找文件的任何标准位置,而是检查仅当前目录。
./
is the current directory. It is largely the same as just file.php
, but in many cases (this one included) it doesn't check any standard places PHP might look for a file, instead checking only the current directory.
来自 PHP文档(注意最后一句):
From the PHP documentation (notice the last sentence):
包含的文件是第一个在每个相对于当前工作目录的include_path条目中查找,然后在当前脚本的目录中查找。例如。如果你的include_path是库,当前工作目录是/ www /,你包括include / a.php,那个文件中包含b.php,b.php首先在/ www / libraries /中查找,然后在/中WWW /包含/。如果filename以./或../开头,则仅在当前工作目录中查找。
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.
这篇关于dot-slash对PHP做什么包括调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!