PHP Exercises : Get the document root directory as defined in the server's configuration file
PHP : Exercise-25 with Solution
Write a PHP script to get the document root directory under which the current script is executing, as defined in the server's configuration file.
Sample Solution: -
<?php // getenv() gets the value of an environment variable $rd = getenv('DOCUMENT_ROOT'); echo $rd."\n"; ?>
PHP Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?