$ _ 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.