For the specific differences between PHP_SELF, SCRIPT_NAME, and REQUEST_URI, see the manuals of each version. Here we will summarize the usage of $ _ SERVER [PHP_SELF], $ _ SERVER [SCRIPT_NAME], and $ _ SERVER [REQUEST_URI, they all return information related to the currently used page address. Some examples are listed here.
For the specific differences between PHP_SELF, SCRIPT_NAME, and REQUEST_URI, see the manuals of each version. Here we will summarize the usage of $ _ SERVER [PHP_SELF], $ _ SERVER [SCRIPT_NAME], $ _ SERVER ['request _ URI '] in a very similar way, they all return information related to the currently used page address. Some examples are listed here.
For the specific differences between PHP_SELF, SCRIPT_NAME, and REQUEST_URI, see the manuals of each version. Here is a summary
$ _ SERVER [PHP_SELF], $ _ SERVER [SCRIPT_NAME], $ _ SERVER ['request _ URI '] are very similar in usage, they all return information related to the currently used page address. Here are some examples to help you determine which are most suitable for your script.
$ _ SERVER ['php _ SELF ']
- Http://www.yoursite.com/example/---/example/index. php
- Http://www.yoursite.com/example/index.php---/example/index. php
- Http://www.yoursite.com/example/index.php? A = test---/example/index. php
- Http://www.yoursite.com/example/index.php/dir/test---/dir/test
When we use $ _ SERVER ['php _ SELF '], no matter whether the accessed URL address has an index. php, it will automatically return index. php. however, if a slash is added after the file name, all the subsequent content will be returned in $ _ SERVER ['php _ SELF '].
$ _ SERVER ['request _ URI ']
- Http://www.yoursite.com/example ---/
- Http://www.yoursite.com/example/index.php---/example/index. php
- Http://www.yoursite.com/example/index.php? A = test---/example/index. php? A = test
- Http://www.yoursite.com/example/index.php/dir/test---/example/index. php/dir/test
$ _ SERVER ['request _ URI '] returns the exact address we wrote in the URL. If the URL is only written to "/", it returns "/".
$ _ SERVER ['script _ name']
- Http://www.yoursite.com/example/---/example/index. php
- Http://www.yoursite.com/example/index.php---/example/index. php
- Http://www.yoursite.com/example/index.php---/example/index. php
- Http://www.yoursite.com/example/index.php/dir/test---/example/index. php
The current file name/example/index. php is used in all the returned results.
From: http://www.cnblogs.com/zcy_soft/archive/2010/10/16/1853239.html