Home >Backend Development >PHP Tutorial >Implementation code for using parse_url() to parse URLs in PHP (detailed explanation of parse_url)_PHP tutorial
PHP parsing URL function: parse_url detailed explanation
parse_url — parses the URL and returns its components
Description
array parse_url ( string $url )
This function Parses a URL and returns an associative array containing the various components that appear in the URL.
This function is not used to verify the validity of the given URL, but to break it down into the parts listed below. Incomplete URLs are also accepted and parse_url() will try to parse them as correctly as possible.
Parameters
url
The URL to be parsed
Return value
For severely unqualified URLs, parse_url() may return FALSE and issue E_WARNING. Otherwise an associative array is returned with (at least one) components:
scheme – like http
host
port
user
pass
path
query – in Question mark? After
fragment – after hash symbol # >
$url = 'http://username:password@hostname/path?arg=value#anchor';