I have a file which is in project folder my wampserver www directory and I want to create a path to this file in my PHP script. I am not sure what is right in accomplishing this as I have seen the use of "./", "../" and the full root directory of "c:/...." I foresee a situation where the use of C: would restrict the usage of the path to only that local machine and I therefore want to use the wamp's root which is www.
Asked
Active
Viewed 692 times
1 Answers
0
To get the document root just read it from the $_SERVER-superglobal.
echo $_SERVER['DOCUMENT_ROOT'];

KingCrunch
- 128,817
- 21
- 151
- 173
-
So I could do something like: $_SERVER['DOCUMENT_ROOT'].folder/filename; I checked my php.ini, the doc_root is empty does this affect anything? thanks – ibiangalex Nov 16 '10 at 13:24
-
Its usually set by the server, if php is not runnig as cgi. – KingCrunch Nov 16 '10 at 14:02