PHP: determine the directory path of the server root

Contributor Icon Contributed by qmchenry Date Icon January 4, 2004  
Tag Icon Tagged: PHP programming

It is sometimes necessary to refer to files in the host filesystem explicitly. By retrieving this information dynamically instead of hard coding it, moving the code from one server or hosting company to another is much simpler.


The fully qualified path of the directory containing the root of the web documents is:

$_SERVER["SITE_HTMLROOT"]

To assign the fully qualified path of images/sadie.gif to the variable $pic:

$var = $_SERVER["SITE_HTMLROOT"].’/images/sadie.gif’;

Previous recipe | Next recipe |
 

Viewing 1 Comment

 
close Reblog this comment
blog comments powered by Disqus