The difference between $_server[php_self] and $_server[script_name in Windows 2003 server PHP

Source: Internet
Author: User
"Php_self"
The file name of the currently executing script, 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 give the result/test.php/foo.bar. The __FILE__ constant contains the absolute path and file name of the current (for example, the containing) file.
"Script_name"
Contains the path to 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, include files).
The main reasons are as follows: $_server[' php_self '? $_server[' php_self ': $_server[' script_name '];
The reasons for finding better are:
When I installed a PHP program on DreamHost Today, I found that the connected address would have an extra cgi-system, but the program's config did not have a problem, and the information was found to be the result of script_name and php_self different problems.
Usually in the test $_server[' script_name ' and $_server[' php_self '] probably don't see any difference, because most of PHP is not running in CGI mode.
But the PHP on the DreamHost is run in CGI, and the difference between the two is obvious.
echo $_server[' Script_name ']; (/cgi-system/php.cgi)
echo $_server[' php_self ']; (/admin/test.php)
A description was found from http://lists.nyphp.org/pipermail/talk/2005-July/015339.html. The foreigner said.
Script_name solves all the problems mentioned
In this thread-it ' s just the script name, without any extra garbage
That might is tacked on by the user. Php_self explicitly includes that
Extra garbage, so solutions on this thread that involve stripping the
Garbage off of Php_self to make it safe is really, really missing the
Point-just use Script_name instead. Please don ' t use FORM action= "";
According to the spec, what's the browser does with that's undefined, so
Even if it works in the current browsers, it might don't work in the future ones

The differences between $_server[php_self] and $_server[script_name in Windows 2003 server PHP are described above, including the contents of Windows 2003 server. You want to be helpful to a friend who is interested in PHP tutorials.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.