Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

A. What does this do?

require ("./file.php"); 

B. in comparison to this?

require ("file.php"); 

(Its not up-one-directory.. which would be)

require ("../file.php"); 
like image 213
Robin Rodricks Avatar asked Feb 23 '09 21:02

Robin Rodricks


People also ask

What does dot dot slash mean in HTML?

This is where the dot slash ./ notation comes in. It means “Look in the current directory.” When you use ./, you tell Ubuntu or Fedora or SUSE or whatever Linux distribution you're using to look in the current directory for the command you wish to run, and completely ignore what's on the application PATH.

What does dot slash mean in Javascript?

./ means the current directory; ../ means the parent of the current directory. Follow this answer to receive notifications. edited Mar 5, 2016 at 22:17.

What do two dots and a slash mean in HTML?

It means to go up one level, to the directory that contains the current directory. – Barmar. Oct 17, 2015 at 0:26. If your current directory is /home/yourname/somefolder , .. means /home/yourname.


1 Answers

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

like image 102
Chris Lutz Avatar answered Sep 28 '22 01:09

Chris Lutz