How can I find the root directory on the server?

How can I find the root directory of my site on the server and how can I refer to a file that is not in the same directory as the file is in PHP?

+3


source to share


1 answer


echo $_SERVER['DOCUMENT_ROOT'];

      

The above line will give you the root directory of your site.

You can define the path directly as a constant somewhere in your shared file including the file



define('PATH_TO_PROJECT_ROOT', '/path/to/projectroot/');

      

and use constant wherever you want

+2


source







All Articles