There's a quirk where this function will return the host as the "path" if there is a leading space.
<?php
$url = ' https://foobar.com:80/mypath/myfile.php';
print_r(parse_url($url));
/*
Array
(
[path] => https://foobar.com:80/mypath/myfile.php
)
*/
print_r(trim(parse_url($url)));
/*
Array
(
[scheme] => https
[host] => foobar.com
[port] => 80
[path] => /mypath/myfile.php
)
*/
?>