Home Web application programming PHP programming PHP: determine the directory path of the server root

PHP: determine the directory path of the server root

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';

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

error: Content is protected !!