Jump to content

[SOLVED] include directory


Recommended Posts

ive not tried the full root yet no, i want it relative to the site and to include it on all pages;

and ive tried include('../member_header.php'); to no avail.

 

can i just ask the .. tells the browser to look a directory abouve the current page?

 

sorry if my wording seems all mumble jumble and thanks!

Yes ../ is to go one level higher. To go down a level you specify the directory in the current level.

 

However I highly suggest PFMaBiSmAd's comment.

 

When using include's always do

include $_SERVER['DOCUMENT_ROOT'] . 'path/to/file.php'

This eliminates the need to use ../ in your paths. PHP will locate files from your websites root folder (where you upload your sites files to).

And even though you got it working where the main file is located now, if you should move the main file up or down a level or reuse that code in a different folder structure, it will stop and you will need to go back and figure out a new relative path.

 

Forming an absolute file system path using DOCUMENT_ROOT will allow the include() statement to work no matter what folder the file is in.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.