Phpparse_url function tutorial _ PHP Tutorial

Source: Internet
Author: User
Phpparse_url function tutorial. Phpparse_url function tutorial parse_url (PHP4, PHP5) parse_url-parse the URL and return its component description mixed parse_url (string $ URL [Summary $ part-1]) php parse_url function tutorial

Parse_url
(PHP 4 and PHP 5)

Parse_url-parse the URL and return its components

Description
Hybrid parse_url (string $ URL [Abstract $ part =-1])
This function parses a URL and returns a URL with an associated array containing all components. There are also differences.

This function does not mean to verify the given url. it not only breaks the above section of it. Some URLs are also accepted, and parse_url () will try to parse them correctly as much as possible.

Parameters

URL
URL resolution. Invalid character substitution _.


Part
Specify a 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 to retrieve a specific URL as a string.


Return value
For URL with severe malformed state, parse_url () may return FALSE and issue E_WARNING. Otherwise, the elements returned by the associated array may be (at least one ):

Plan-such as web site
Master
Port
User
Pass
Path
Question mark after query?
Segment-Post hashmark #

If some parameters specify to return a string rather than an array.

Modify

Version description
5.1.2 time element parameters


Instance

$ Url = 'http: // username: password @ hostname/path? Arg = value # anchor ';

Print_r (parse_url ($ url ));

Echo parse_url ($ url, PHP_URL_PATH );
?>
The above example will output:

Array
(
[Scheme] => http
[Host] => hostname
[User] => username
[Pass] => password
[Path] =>/path
[Query] => arg = value
[Fragment] => anchor
)
/Path


Http://www.bkjia.com/PHPjc/445463.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445463.htmlTechArticlephp parse_url function tutorial parse_url (in PHP 4, in PHP 5) parse_url-parse the URL and return its component description mixed parse_url (string $ URL [Summary $ Section =-1]) this task...

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.