You could also use realpath.
realpath(".")
returns your document root.
You can call realpath with your specific path. Note that it will NOT work if the target folder or file does not exist. In such case it will return false, which could be useful for testing if a file exists.
In my case I needed to specify a path for a new file to be written to disk, and the solution was to append the path relative to document root:
$filepath = realpath(".") . "/path/to/newfile.txt";
Hope this helps anyone.