I have a server where the public root is located at: /var/www/example.com/html/.
Using $_SERVER['DOCUMENT_ROOT']); I get the following result:
/var/www/example.com/html/
What $_SERVER array key would I use to get the path directly above the public root? That is, the one here:
/var/www/example.com/
This will have to work on multiple environments, such as local and live. Not sure if there’s some way of doing ./ document_root sort of thing.
dirname()returns the parent directory of a directory and is platform independent.Should return:
If you need the trailing slash then you can append
DIRECTORY_SEPARATOR: