PHP_SELF wont give you script path alone, it gives full path inclusive file.name. And "dirname(__FILE__)" gives you system path, nothing for web.
$full_url_path = "http://" . $_SERVER['HTTP_HOST'] . preg_replace("#/[^/]*\.php$#simU", "/", $_SERVER["PHP_SELF"]);