DOCUMENT ROOT is the path where application is stored on file system. In some application’s we need to use absolute path of any file or script in our php script, While development we really don’t know where application will be hosted on server. In that case we can use php function getenv() to get the document root of application dynamically using PHP script.
<?php //PHP Script to find Document Root of Application $docroot = getenv("DOCUMENT_ROOT"); echo $docroot; ?>
As per above PHP script actual DOCUMENT ROOT of application will be stored in $docroot variable which can be used further in application.