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:
- $_server[' php_self ') reflects the PHP program itself;
- $_server[' Script_name ' reflects the program file itself (which is useful when the page needs to point to itself);
- $_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 ']