Forum Moderators: coopster

Message Too Old, No Replies

How do I determine the full server path for require()?

At wit's end working with a yahoo web hosting account

         

zollerwagner

2:26 am on May 15, 2006 (gmt 0)

10+ Year Member



When I run phpinfo on my yahoo webhosting account, part of what it returns is the following:

_SERVER["REAL_ROOT"] = /
_SERVER["DOCUMENT_ROOT"] = /
_ENV["REAL_ROOT"] = /
_ENV["DOCUMENT_ROOT"] = /

Does that mean that / is the full server path to root?

I'm trying to be sure I'm using the right path to the called (included) file.

I have only gotten require() to work when the calling file is located in the root folder. If the calling file is in a folder in the root folder, like /test/callingFile.php, the require fails.

[The called (included) file, however, can be in a folder in the root folder.]

Surprisingly, this did not work for any calling file outside of the root folder:
require($_server['DOCUMENT_ROOT']."/calledFile.php");

eelixduppy

2:43 am on May 15, 2006 (gmt 0)




Surprisingly, this did not work for any calling file outside of the root folder:
require($_server['DOCUMENT_ROOT']."/calledFile.php");

The file you are trying to require is //calledFile.php. Try this:
require($_SERVER['DOCUMENT_ROOT']."calledFile.php");

eelix

zollerwagner

7:26 pm on May 15, 2006 (gmt 0)

10+ Year Member



That's a good point. It's interesting that both work in the root directory. I wouldn't expect "//" to work.

I had reported this problem to Yahoo and am now seeing different results than when I first began this thread, so maybe they've fixed something.

I'll start a separate thread for the subdomain problem I'm having now.