Jump to content

Relative Paths


Recommended Posts

Not sure if this is the right area for this, but I have a question about using PHP requires. I currently am building my site and using the require command to include a table of contents on my pages. However, I have to change the paths every time I change from testing locally (using Apache server, PHP 5) to uploading to my live site. Is there anything I can do to make both use the same paths?

Link to post
Share on other sites

I ran into the same thing

On my local server the root folder is used by the server

so I use folders for each site

and can't get include $_SERVER['DOCUMENT_ROOT']."/filename.php";

to work locally.

So I just use relative or put the include files in a sub folder and

include ("folder/filename.php");

 

You could create two text files for local and remote called path.php

and include it and have it set the include path for where ever you are.

Link to post
Share on other sites
  • 3 weeks later...
I ran into the same thing

On my local server the root folder is used by the server

so I use folders for each site

and can't get include $_SERVER['DOCUMENT_ROOT']."/filename.php";

to work locally.

So I just use relative or put the include files in a sub folder and

include ("folder/filename.php");

 

You could create two text files for local and remote called path.php

and include it and have it set the include path for where ever you are.

Well I'd sort of given up on this but then I remembered your comment about using the two text files. Could you explain that in a little more detail? Perhaps give me an example?

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.

×
×
  • Create New...