Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
grahamgr3

Using ./ When Including Files?

Recommended Posts

In the ecommerce book, in chapter 3, you include files like so: include('./includes/header.html');

doesn't include('includes/header.html') do the same thing? Why use the ./  I don't understand. This wasn't covered in the other book I read from you php and mysql 4th edition.

Share this post


Link to post
Share on other sites

Hi,

 

In Larry's book, PHP & MySQL for Dynamic Websites, on page 90, he has a good explanation:

 

"As a best practice, use the ./filename syntax when referring to files within the same directory as the parent (including) file, ...  A file stored in a directory above the parent file would be included using the path ../filename, and a file stored in a directory below the parent file would use ./directory/filename".

 

You can also go up (../) and then down again if necessary - e.g., ../next_level_up_directory/then_down_from_there_directory/filename.

 

I believe that they are referred to as 'document relative paths'.

 

Hope it helps, Cheers.

Share this post


Link to post
Share on other sites

As far as I know, there's no difference between using ./includes/header.html and includes/header.html, as both refer to the same file. The former explicitly says to start in the current directory whereas the latter implicitly states that. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...