The difference between PHP $_server[' php_self ', $_server[' script_name '] and $_server[' Request_uri ']

Source: Internet
Author: User

Http://www.5idev.com/php/index.php/test/foo?username=hbolive
    • $_server[' php_self '] get:/php/index.php/test/foo
    • $_server[' Script_name '] get:/php/index.php
    • $_server[' Request_uri '] get:/php/index.php/test/foo?username=hbolive

As you can see from this example:

    1. $_server[' php_self ') reflects the PHP program itself;
    2. $_server[' Script_name ' reflects the program file itself (which is useful when the page needs to point to itself);
    3. $_server[' Request_uri ') reflects the full URL address (excluding host name).

In fact, from their respective names, can also reflect the subtle differences between them.

In particular, for the following address:

http://www.5idev.com/
    • $_server[' php_self '] get:/index.php
    • $_server[' Script_name '] get:/index.php
    • $_server[' Request_uri '] get:/

As for someone who mentions $_server[' php_self ' and $_server[' script_name ', there is a difference between PHP running in CGI mode. Because PHP is not uncommon in CGI mode, testing is cumbersome and is not described here. If this is the case, you can pay attention and test yourself.

Http://www.5idev.com/p-php_server_php_self_script_name_request_uri.shtml

The difference between PHP $_server[' php_self ', $_server[' script_name '] and $_server[' Request_uri ']

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.