473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Difference between $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF']

Hi All,

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?

Thanks!

Sincerely,
-Josh
Jul 17 '05 #1
3 5457
"Joshua Beall" <jb****@donotspam.remove.me.heraldic.us> wrote in message
news:Eq1rd.2268$M57.2218@trnddc01...
Hi All,

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?

Thanks!

Sincerely,
-Josh


Good question. PHP_SELF is apparently SCRIPT_NAME + PATH_INFO. If the URL is
http://www.example.net/index.php/hello/world, PHP_SELF is
/index.php/hello/world while SCRIPT_NAME is just /index.php.
Jul 17 '05 #2
Chung Leong wrote:
PHP_SELF is apparently SCRIPT_NAME + PATH_INFO.
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.
If the URL is http://www.example.net/index.php/hello/world,
PHP_SELF is /index.php/hello/world while SCRIPT_NAME is just
/index.php.


Right.

--
Jock
Jul 17 '05 #3

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...
Chung Leong wrote:
PHP_SELF is apparently SCRIPT_NAME + PATH_INFO.


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.
If the URL is http://www.example.net/index.php/hello/world,
PHP_SELF is /index.php/hello/world while SCRIPT_NAME is just
/index.php.


Right.

--
Jock


Well, the info I provided was from experimentation.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Salve Håkedal | last post by:
When I select Februar here and sends, selection returns to Januar. I know why: no option is marked selected... But can php get this right in an easy way? <html><head><title>Part of a bigger...
13
by: deko | last post by:
I'm trying to identify which named anchor is currently being viewed on a page. Although the address bar of my browser shows #whatever appended to the end of the url, I can't seem to find it in a...
10
by: tHatDudeUK | last post by:
My form action code to submit values to itself have stopped working using the code form action = <?=$_SERVER?> This code used to work My web host recently told me they enabled phpsuexec...
1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
10
by: Jim Carlock | last post by:
Looking for a way to extract the path from the pfqpn (partially full qualified path name). $sThisServer = $_SERVER; // returns either aquaticcreationsnc.com or www.aquaticcreationsnc.com ...
7
by: Dynamo | last post by:
I am using values stored an $_POST array to display records from a table before asking the user if he is sure he wants to delete them. If the user confirms then the records are deleted. Without...
5
by: Tom | last post by:
I have a function that restricts access to a page to logged in users. When a user who isn't logged in goes to the page, it will dynamically generate a login form. I'm trying to use it in...
4
by: Jim Carlock | last post by:
Are the XSS / Cross Site Scripting attacks fixed in Version 4.44? I'm seeing that $_SERVER doesn't return the $_SERVER appended to it. I was just messing with a few things and noticed that...
4
by: vinnie | last post by:
can someone explain me with an easy example what the function for? I've read on the php.net, but didn;t really catch the point. I'm a newbie. Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.