NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
name of the running script


Joined: 31 Jul 2005
Posts: 16
Reply with quote
Any suggestions? I don't know if this is a bug or just a misconfiguration.

Expected behaviour:
The $_SERVER variable SCRIPT_NAME should be the name of the running script:
Quote:
'SCRIPT_NAME'

Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.


Actual behaviour:
It works as expected when running under apache, but returns only "/php/php.exe" when running under the built-in SRV Server.

Workaround:
Use $_SERVER['PHP_SELF'] instead.

_________________
jorgen*fabeljet,com
View user's profileFind all posts by j0rg3nSend private messageVisit poster's website
RT*M


Joined: 31 Jul 2005
Posts: 16
Reply with quote
I should have guessed: The documentation for $_SERVER is not alphabetical. The documentation for PHP_SELF implies (somewhat cryptically) that SCRIPT_NAME is the path of the PHP engine when running in CGI mode:
Quote:
'PHP_SELF'

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://myserver/test.php/mywebsite would be /test.php/mywebsite. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.


So: Using PHP_SELF is the Right Thing, and has been so since PHP 4.3.0.

_________________
jorgen*fabeljet,com
View user's profileFind all posts by j0rg3nSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Correct. While Php is run as CGI module, SCRIPT_NAME is pointing to php executable. It's true when you use php CGI under Apache too.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
name of the running script
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic