The difference between $ _ SERVER [PHP_SELF] and $ _ SERVER [SCRIPT_NAME] in php. "PHP_SELF" indicates the file name of the script being executed, which is related to documentroot. For example, use $ _ SERVER [P "PHP_SELF" in the script with the URL address www. jb51.nettest. phpfoo. bar"
The file name of the script being executed, which is related to document root. For example, using $ _ SERVER ['php _ SELF '] in a script with a URL address of http://www.jb51.net/test.php/foo.bar will get the result of/test. PHP/foo. bar. The _ FILE _ constant contains the absolute path and FILE name of the current (such as include) FILE.
"SCRIPT_NAME"
The path that contains the current script. This is useful when the page needs to point to itself. _ FILE _ contains the absolute path and FILE name of the current FILE (for example, including the FILE ).
The main reasons are as follows: $ _ SERVER ['php _ SELF ']? $ _ SERVER ['php _ SELF ']: $ _ SERVER ['script _ name'];
The better reason is:
Today, when I installed a set of PHP programs on the Dreamhost, I found that there would be an additional cgi-system address, but the config of the program has no problem, after checking the information, we found the problem caused by different SCRIPT_NAME and PHP_SELF.
Generally, the website hosting $ _ SERVER ['script _ name'] and $ _ SERVER ['php _ SELF '] on the current machine cannot be seen as different, because most PHP does not run in CGI mode.
However, PHP on DreamHost runs in CGI mode, and there are obvious differences between the two.
Echo $ _ SERVER ['script _ name']; // (/cgi-system/php. cgi)
Echo $ _ SERVER ['php _ SELF ']; // (/admin/test. PHP)
Found a description from the http://lists.nyphp.org/pipermail/talk/2005-July/015339.html. Said by foreigners.
SCRIPT_NAME solves all the problems mentioned
In this thread-it's just the script name, without any extra garbage
That might be tacked on by the user. PHP_SELF explicitly provided des that
Extra garbage, so solutions in this thread that involve stripping
Garbage off of PHP_SELF to make it safe are really, really missing
Point-just use SCRIPT_NAME instead. Please don't use form action = "";
According to the spec, what the browser does with that is undefined, so
Even if it works in current browsers, it might not work in future ones
The file name of the script being executed. it is related to document root. For example, use $ _ SERVER ['p...