Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Joshua Beall
November 30, 2004, 10:43 pm
rate this thread
What is the difference between $_SERVER['SCRIPT_NAME'] and
$_SERVER['PHP_SELF'], and which is better to use?
According to the CGI 1.1 spec (http://hoohoo.ncsa.uiuc.edu/cgi/env.html ),
SCRIPT_NAME is not something specific to Apache (if I understand that
correctly). But where does PHP_SELF come from? What creates that?
According to http://php.net/reserved.variables , PHP has no control over the
$_SERVER array. Quote:
"The entries in this array are created by the webserver. There is no
guarantee that every webserver will provide any of these; servers may omit
some, or provide others not listed here. That said, a large number of these
variables are accounted for in the CGI 1.1 specification, so you should be
able to expect those."
So, of those two, should I be concerned about one being less portable than
the other, or that one might change in the future?
Re: Difference between $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF']
PHP_SELF has nothing to do with script names, file names,
directories or the organisation of the server; so far as I
can see, it's the path component of the URI. The Manual is
wrong here. Also, its description of SCRIPT_NAME, though
vague, is almost passable.