Parse_url functions in PHP Learn to understand the ___ function

Source: Internet
Author: User

Some things although very simple, but feel if they do not do, may be a short period of time to forget, in the process of blogging is tantamount to further deepen their own impression, intend to look at the laravel of the source code, broaden their horizons

Looking at the server.php entry file, you see the following code

$uri = UrlDecode (
    parse_url ($_server[' Request_uri '), Php_url_path)
);
I see after feeling a little strange, $_server[' Request_uri '] returned not all the content after the domain name, Parse_url is not used to parse the URL, why can be used to parse a string that is not a URL, so I started to test, wrote the following code

$a = '/oop?b=1 ';
$b =  Parse_url ($a, php_url_path);
Var_dump ($b);

Output value is

String (4) "/oop"
When the code is

$a = '/oop?b=1 ';
$b =  Parse_url ($a);
Var_dump ($b);


Output value is

Array (2) {[' Path ']=> string (4) '/oop ' [' Query ']=> string (3) ' B=1 '}

So, come on, Parse_url, this function is now not necessarily a very standard URL to return to,

After the test, I looked at the description of the function in the PHP manual.

It was repaired in the 5.4.7.

2016-11-8 22:30 Edit


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.