$_SERVER['DOCUMENT_ROOT'] would return /home/user/public_html
Now thats fine if your software or script is being using in the main/root directory but what if its being used in a folder or a folder of a folder how do you get that path. Especially when you don't know where a user is going to use it.
something like this;
while ( file_exists ( $fileExtension.'includes/config.php' ) == false )
{
$fileExtension .= '../';
}
would work alright, but for some things I actually want to use the full path.
So if they had a user had the script in www.example.com/folder/subfolder/demo-script/
The base path would be /home/user/public_html/folder/subfolder/demo-script/