What does the dot-slash do to PHP include calls?

./ 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.

From the PHP documentation (notice the last sentence):

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.

Leave a Comment