#21154 [Opn]: $_SERVER[PHP_SELF] empty in cgi
| From: | george at omniti dot com | Date: | Mon, 23 Dec 2002 16:25:07 +0000 |
| Subject: | #21154 [Opn]: $_SERVER[PHP_SELF] empty in cgi | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-28282@lists.php.net to get a copy of this message | ||
ID: 21154
User updated by: george@omniti.com
Reported By: george@omniti.com
Status: Open
Bug Type: Other web server
Operating System: mac osx
PHP Version: 4.3.0RC4
New Comment:
Doesn't make sense to me. Even if not PHP_SELF, then at
least SCRIPT_FILE or SCRIPT_FILENAME (both also blank)
should be defined. These are certainly well-defined in any
context.
Previous Comments:
------------------------------------------------------------------------
[2002-12-23 10:19:00] philip@php.net
Why does CLI have all of these?
Why is PHP_SELF empty as opposed to not existing at all?
------------------------------------------------------------------------
[2002-12-23 05:25:55] wez@php.net
CGI needs specific environmental variables to be set in order to
determine PHP_SELF.
Running from the command line does not (usually) have the environment
set up as described in the CGI spec, and that is the reason it's
missing.
If you think about it, it makes sense; how can it determine the
relative path to the root of the web server when it is not actually
running under a web server?
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
States:
"
'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://example.com/test.php/foo.bar would
be /test.php/foo.bar.
If PHP is running as a command-line processor, this variable is not
available.
"
So I'm marking this report as bogus (nothing personal!).
------------------------------------------------------------------------
[2002-12-22 21:36:14] george@omniti.com
I should note that the cgi and cli are both being run by
hand from a shell (not exec'd from a webserver).
------------------------------------------------------------------------
[2002-12-22 21:31:12] george@omniti.com
<?php
print_r($_SERVER);
?>
returns:
22:28:26(george@ool-18bced28)[~/Advanced PHP/examples]> php
a.php
Content-type: text/html
X-Powered-By: PHP/4.3.0-dev
Array
(
[HOME] => /Users/george
[SHELL] => /bin/tcsh
[USER] => george
[LANG] => en
[PATH] => /sw/bin:/sw/sbin:/bin:/usr/bin:/Users/george/
bin:/usr/sbin:/opt/GN
Upgcc/bin:/opt/GNUxemacs/bin:/usr/local/bin:/usr/local/
sbin:/usr/openwin/bin:/us
r/dt/bin:/usr/ccs/bin:/usr/proc/bin:/usr/ucb:/usr/X11R6/
bin:/sw/bin:/sw/sbin:.:/
usr/X11R6/bin
[__CF_USER_TEXT_ENCODING] => 0x1F5:0:0
[TERM] => vt100
[PWD] => /Users/george/Advanced PHP/examples
[HOSTTYPE] => macintosh
[VENDOR] => apple
[OSTYPE] => darwin
[MACHTYPE] => powerpc
[SHLVL] => 1
[LOGNAME] => george
[GROUP] => staff
[HOST] => ool-18bced28.dyn.optonline.net
[HOSTTAG] => maya [Omniti/mobile]
[MANPATH] => /usr/share/man:/usr/openwin/share/man:/
usr/man:/usr/local/man:/
opt/SUNWwabi/man:/usr/local/lib/perl5/man:/opt/GNUpgcc/
man:/opt/GNUxemacs/man
[INFOPATH] => /sw/share/info:/sw/info:/usr/local/share/
info:/usr/local/lib/i
nfo:/usr/local/info:/usr/share/info
[PERL5LIB] => /sw/lib/perl5
[EDITOR] => vi
[VISUAL] => vi
[DISPLAY] => :0.0
[CVS_RSH] => ssh
[OPENWINHOME] => /usr/openwin
[XFILESEARCHPATH] => /usr/dt/lib/%T/%N%S
[XGLHOME] => /opt/SUNWits/Graphics-sw/xgl
[LD_LIBRARY_PATH] => /usr/lib:/usr/dt/lib:/usr/openwin/
lib:/usr/ucblib:/usr/
local/lib:.
[XILHOME] => /opt/SUNWits/Graphics-sw/xil
[MOTIFHOME] => /usr/dt
[UIDPATH] => /opt/SUNWmfdm
[XMBINDDIR] => /usr/dt/lib/bindings
[GUIDEHOME] => /opt/SUNWguide
[PHP_SELF] =>
[argv] => Array
(
[0] => a.php
)
[argc] => 1
)
note PHP_SELF is unset. Running the same under cli yields
correct result:
22:31:00(george@ool-18bced28)[~/Advanced PHP/examples]> ~/
src/php4-STABLE-200212
210230/sapi/cli/php ~/Advanced\ PHP/examples/a.php
Array
(
[HOME] => /Users/george
[SHELL] => /bin/tcsh
[USER] => george
[LANG] => en
[PATH] => /sw/bin:/sw/sbin:/bin:/usr/bin:/Users/george/
bin:/usr/sbin:/opt/GN
Upgcc/bin:/opt/GNUxemacs/bin:/usr/local/bin:/usr/local/
sbin:/usr/openwin/bin:/us
r/dt/bin:/usr/ccs/bin:/usr/proc/bin:/usr/ucb:/usr/X11R6/
bin:/sw/bin:/sw/sbin:.:/
usr/X11R6/bin
[__CF_USER_TEXT_ENCODING] => 0x1F5:0:0
[TERM] => vt100
[PWD] => /Users/george/Advanced PHP/examples
[HOSTTYPE] => macintosh
[VENDOR] => apple
[OSTYPE] => darwin
[MACHTYPE] => powerpc
[SHLVL] => 1
[LOGNAME] => george
[GROUP] => staff
[HOST] => ool-18bced28.dyn.optonline.net
[HOSTTAG] => maya [Omniti/mobile]
[MANPATH] => /usr/share/man:/usr/openwin/share/man:/
usr/man:/usr/local/man:/
opt/SUNWwabi/man:/usr/local/lib/perl5/man:/opt/GNUpgcc/
man:/opt/GNUxemacs/man
[INFOPATH] => /sw/share/info:/sw/info:/usr/local/share/
info:/usr/local/lib/i
nfo:/usr/local/info:/usr/share/info
[PERL5LIB] => /sw/lib/perl5
[EDITOR] => vi
[VISUAL] => vi
[DISPLAY] => :0.0
[CVS_RSH] => ssh
[OPENWINHOME] => /usr/openwin
[XFILESEARCHPATH] => /usr/dt/lib/%T/%N%S
[XGLHOME] => /opt/SUNWits/Graphics-sw/xgl
[LD_LIBRARY_PATH] => /usr/lib:/usr/dt/lib:/usr/openwin/
lib:/usr/ucblib:/usr/
local/lib:.
[XILHOME] => /opt/SUNWits/Graphics-sw/xil
[MOTIFHOME] => /usr/dt
[UIDPATH] => /opt/SUNWmfdm
[XMBINDDIR] => /usr/dt/lib/bindings
[GUIDEHOME] => /opt/SUNWguide
[PHP_SELF] => /Users/george/Advanced PHP/examples/a.php
[SCRIPT_NAME] => /Users/george/Advanced PHP/examples/
a.php
[SCRIPT_FILENAME] => /Users/george/Advanced PHP/
examples/a.php
[PATH_TRANSLATED] => /Users/george/Advanced PHP/
examples/a.php
[DOCUMENT_ROOT] =>
[argv] => Array
(
[0] => /Users/george/Advanced PHP/examples/
a.php
)
[argc] => 1
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21154&edit=1