Jump to content
Larry Ullman's Book Forums

Syntax Of String Provided To Require()


Recommended Posts

Hi - While working through the ch. 2 script examples, and simultaneously working on separate a website project, I noticed a subtle difference in strings provided to require().  Here is an example:

require ('Includes/Config.php');

vs.

require ('./Includes/Config.php');

The second command contains a period and forward slash before the folder and file are stated.  As far as I can tell, the web page behaves the same no matter which string is provided to require().  What does "./" mean?  What is the purpose of prefixing the required file string with "./"?  I'm guessing it has something to do with folder structure...

 

Link to comment
Share on other sites

The single period (.) refers to the current directory in UNIX systems (http://en.wikipedia.org/wiki/Working_directory).

I can't think of any cases in which specifying ./ before a relative path vs. just the relative path would make a difference, but maybe there is one.

 

I used to specify ./ before relative paths to be more precise, but as far as I could tell, it didn't affect anything, so I stopped doing it.

Link to comment
Share on other sites

 Share

×
×
  • Create New...