I have an absolute path of a file, Is there a way to get the file absolute path
http://domainname/rootfolder/filename.php
and I wanna get something like
/home/domainname/public_html/foldername/filename.php
This is the easiest way:
$path = parse_url('http://domainname/rootfolder/filename.php', PHP_URL_PATH);
//To get the dir, use: dirname($path)
echo $_SERVER['DOCUMENT_ROOT'] . $path;
That'll print you the full path.
Documentation: