Forum Moderators: coopster

Message Too Old, No Replies

php include path

can I use a relative path

         

icpooreman

3:03 am on Jul 11, 2005 (gmt 0)

10+ Year Member



hey I've creating several html pages which include php files and I want to link to them relatively because I don't know what my domain will be and I'm using a test server on my local computer. So I want something to the effect of /phpfolder/myphpfile.php so that I can have the same link in all of my html pages. I've been trying to figure out how to do this but with no real success. I've read something about php storing the root dir in a variable but I couldn't get it to work. I'm very new with php and any advice someone has on a good way to do this would be appreciated.

Birdman

3:14 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's the global $_SERVER['DOCUMENT_ROOT'] that you want I think, I usually create a folder for includes in the root folder. Then I include like so:

include( $_SERVER['DOCUMENT_ROOT'] . '/includes/myfile.php');

That way, as long as you create the "includes" folder in root, it will be portable from server to server.

Cheers