Including files from site root with PHP

When referencing “/”, php will interpret the forward slash as the root of the file system and NOT the root of the website. to deal with (or include) the file, you must specify its location by ether an absolute or relative path.

If a File is located at /var/www/syswide/util.php, and the php script you’re working on is at /var/www/media/index.php. you can refer to your file ether by its absolute path (/var/www/syswide/util.php) or by its relative path:
../syswide/util.php.
The same principle should be applicable on MS-Windows as well.

note: “..” refers to the parent directory.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: