note 28024 added to reserved.variables
| From: | php dot net at werner-ott dot de | Date: | Mon, 30 Dec 2002 09:51:18 +0000 |
| Subject: | note 28024 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41462@lists.php.net to get a copy of this message | ||
Concerning $_SERVER['PHP-SELF']:
As of PHP 4.3.0 it is no longer true that "if PHP is running as a command-line processor, this
variable [PHP_SELF] is not available.". At least for the CLI processor.
Instead, the variable is set to the filename you supplied for starting the PHP script. If you, for
example, start your script from the shell by executing "php -f
/usr/local/httpd/htdocs/test.php", $_SERVER['PHP_SELF'] will be set to
"/usr/local/httpd/htdocs/test.php".
In the past I've used $_SERVER['PHP_SELF'] as a switch in my scripts to support both
execution modes:
// DOES NOT WORK ANY MORE FOR PHP >= 4.3.0:
if (empty($_SERVER['PHP_SELF']))
// run as command line script
else
// run as dynamic web page
Since the above does not work any more, using the $_SERVER['SERVER_*'] variables the same
way may be a solution to the problem, i.e.
// SHOULD WORK FOR PHP >= 4.3.0
if (empty($_SERVER['SERVER_SOFTWARE']))
// run as command line script
else
// run as dynamic web page
br
WOT
--
http://www.php.net/manual/en/reserved.variables.php
http://master.php.net/manage/user-notes.php?action=edit+28024
http://master.php.net/manage/user-notes.php?action=delete+28024
http://master.php.net/manage/user-notes.php?action=reject+28024