Php_self, Script_name, Request_uri difference
$_server[php_self], $_server[script_name], $_server[' Request_uri ') are very similar in usage, and they return information about the address of the page that is currently being used, Here are some relevant examples to help determine which ones are best suited 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 '], it automatically returns index.php regardless of whether or not the URL address is index.php. But if you add a slash after the file name, you'll return all of the contents back to the $_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 that we wrote in the URL, and returns "/" If the URL is written only to "/"
$_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
is the current file name in all returns/example/index.php
Php_self, Script_name, Request_uri difference