\n$component<\/span><\/td>\n | Specify any Component otherwise blank will return an array. Components are PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT<\/td>\n<\/tr>\n<\/table>\nparse_url example 1:<\/h4>\n\r\n$parseUrl = parse_url(\"http:\/\/www.example.com\");\r\nprint_r($parseUrl);\r\n<\/pre>\nThe output of the above code is below. Parse url split url into 2 indices. First one is scheme which is http and second is a host name which is www.example.com<\/p>\n Output:<\/h4>\n\r\nArray\r\n(\r\n [scheme] =>http\r\n [host] => www.example.com\r\n)\r\n<\/pre>\nparse_url example 2:<\/h4>\n\r\n$parseUrl2 = parse_url(\"http:\/\/www.example.com:8080?name=ahsan&title=developer#hrefID\");\r\nprint_r($parseUrl2);\r\n<\/pre>\nIn the above code, a very long url passed in parse_url function and parse_url split url into different indexes of array.<\/p>\n Output:<\/h4>\n\r\nArray\r\n(\r\n [scheme] =>http\r\n [host] => www.example.com\r\n [port] => 8080\r\n [query] =>name=ahsan&title=developer\r\n [fragment] =>hrefID\r\n)\r\n\r\n<\/pre>\nparse_url example 3:<\/h4>\n\r\n$ftpURL = parse_url('ftp:\/\/user:password@example.com\/pub\/file.txt');\r\nprint_r($ftpURL);\r\n<\/pre>\nIn the above example ftp url with user, password and file path pass in the parse_url and parse_url split ftp url into different indexes.<\/p>\n Output:<\/h4>\n\r\nArray\r\n(\r\n [scheme] =>ftp\r\n [host] => example.com\r\n [user] =>user\r\n [pass] =>password\r\n [path] => \/pub\/file.txt\r\n)\r\n<\/pre>\n\n<\/ins> \n |