Very often you need to be able to pull out parts of the information that is contained within a URL. Like the port, the protocol, etc.
This is where the parse_url function is so handy.
Let’s look at the following code:
$url_info = parse_url('http://username:password@www.phpdeveloping.co.za:80/directory/?arg=value#anchor'); print_r($url_info);
The output will be something like:
Array ( [scheme] => http [host] => www.phpdeveloping.co.za [user] => username [pass] => password [path] => /directory [port] => /80 [query] => arg=value [fragment] => anchor )

