Page 2 of 2

Posted: Wed Jul 26, 2006 3:43 pm
by vchris
Why don't you simply use absolute paths instead?

I never said relative path didn't work. I just said I want absolute path to work for php files and it already works for images and css. It seems like the problem is with the function include/require/require_once.

Posted: Thu Jul 27, 2006 3:07 am
by Ollie Saunders
I'm getting the impression from people that includes a somehow relative to the document root.
Remember this is not the case. They are relative to the location of the script being executed, the two aren't necessarily the same.

Posted: Thu Jul 27, 2006 10:54 am
by RobertGonzalez
That's why I always set a var to my document root and use that var. Not dependence on $_SERVER vars or trying to figure anything out programmatically. Just tell the script where everything starts. Then use that as the starting point.

Posted: Thu Jul 27, 2006 8:55 pm
by vchris
So why wouldn't the function include/require/require_once not work?

Posted: Fri Jul 28, 2006 5:08 am
by Ollie Saunders
Because you were trying to use $_SERVER['DOCUMENT_ROOT'] when DOCUMENT_ROOT isn't present in $_SERVER.

Posted: Fri Jul 28, 2006 3:37 pm
by vchris
You're right! I got this when displaying $_SERVER['DOCUMENT_ROOT']:
Notice: Undefined index: DOCUMENT_ROOT in C:\Inetpub\wwwroot\MySite\mf\index.php on line 15
How would I set the document root?

Posted: Fri Jul 28, 2006 8:21 pm
by RobertGonzalez
Have a look at dirname() and pathinfo().

Posted: Sat Jul 29, 2006 11:56 am
by vchris
hmmm... Well I tested the absolute path and it seems to start from the C:. How can I have it start in mysite's folder? I have IIS 5.1.

Posted: Sat Jul 29, 2006 9:40 pm
by RobertGonzalez
What about realpath()?