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 s
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:
parse_url
DOCUMENT_ROOT
dirname