• 0

PHP include not mapping properly...


Question

I have setup WAMP on a spare box. The site physically is located at:

"c:/wamp/www/MYSITE/public_html/"

The apache doc root has been set to:

C:\wamp\www\MYSITE\public_html

If i have a file in the public_html folder, I can include('/assets/includes/global.php')

But if the file is 1 folder in, such as public_html/myfolder, I cannot include as above...

It seems that the first / in the include is mapping all the way back to C: so I need to include('/wamp/www/MYSITE/public_html/assets/includes/global.php');

What gives? Surely it should just map back to c:/wamp/www/MYSITE/public_html/

?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I think include works reliably in one of three cases

- relative to the file it's in

- found in PATH

- fully qualified path

The thing with '/.... usually is used for URLs, as it maps to the root of the domain. Possibly the slash gets stripped with include , therefore your example works as if the slash was not present, i.e. the first one works, the second one is broken

apply the rules above and it should be reliable. Maybe get the $_SERVER['DOCUMENT_ROOT'] in your script and prepend this before the short path to the include ?

I've used a Front Controller, or .htaccess with php_value auto_prepend_file with success before, to get a set of site variables in all necessary places automatically

Just my $.02

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.