Explore: Parse URL parsing URL, returning its components _php tutorial

Source: Internet
Author: User
(PHP 4, PHP 5)
parse_url-parse URL, return its components
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 validate the legitimacy of a given URL, but to decompose it into the parts listed below. An incomplete URL is also accepted, and Parse_url () tries to parse it as correctly as possible.

The URL to resolve
return value
A url,parse_url () that is severely unqualified may return FALSE and emit e_warning. Otherwise, an associative array is returned, with the component (at least one):

Scheme-such as HTTP
Query-in question marks? After
Fragment-After hash symbol #
Example 2369. Parse_url () example
$url = ' Http://username:password@hostname/path?arg=value#anchor ';
Print_r (Parse_url ($url));
The example above will output:
Array (Scheme) + HTTP [host] + hostname [user] = username [pass] = password [path] +/path [query] =& Gt Arg=value [Fragment] = anchor)
Note: This function cannot be used for relative URLs.
Note: Parse_url () is specifically used to parse URLs instead of URIs. However, there is an exception to the need for backward compatibility with PHP, which allows three slashes (file:///) for the file://protocol. )。 No other protocol can do that.

http://www.bkjia.com/PHPjc/327614.html www.bkjia.com true http://www.bkjia.com/PHPjc/327614.html techarticle Parse_url (PHP 4, PHP 5) parse_url-parses the URL and returns its component description array Parse_url (string $url) This function parses a URL and returns an associative array, contained in the u...< /c5>

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.