parse_url

PHP 4, PHP 5, PHP 7, PHP 8
parse_url - Parse a URL and return its components

Example #1 A parse_url example

Result: array(8) { ["scheme"]=> string(4) "http" ["host"]=> string(8) "hostname" ["port"]=> int(9090) ["user"]=> string(8) "username" ["pass"]=> string(8) "password" ["path"]=> string(5) "/path" ["query"]=> string(9) "arg=value" ["fragment"]=> string(6) "anchor" } string(4) "http" string(8) "username" string(8) "password" string(8) "hostname" int(9090) string(5) "/path" string(9) "arg=value" string(6) "anchor"
PHP Version:

Example #2 A parse_url example with missing scheme

Result: array(3) { ["host"]=> string(15) "www.example.com" ["path"]=> string(5) "/path" ["query"]=> string(17) "googleguy=googley" }
PHP Version:


Example #3 of parse_url

PHP Version:


Function parse_url:

URLs Functions

Most used PHP functions