php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39207 Some $_SERVER variables are missing when executing php5-cgi from shell
Submitted: 2006-10-20 08:14 UTC Modified: 2006-10-20 14:29 UTC
From: konradg at irc dot pl Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.1.6 OS: Linux 2.6.17.6-amd64, Debian 3.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: konradg at irc dot pl
New email:
PHP Version: OS:

 

 [2006-10-20 08:14 UTC] konradg at irc dot pl
Description:
------------
Some $_SERVER variables in fastcgi version (php5-cgi) are missing _only_ when executing directly from shell command line. 

Variables are:
_SERVER["PHP_SELF"] (set but no value)
_SERVER["SCRIPT_NAME"] (not set)
_SERVER["SCRIPT_FILENAME"] (not set)
_SERVER["PATH_TRANSLATED"] (not set)
_SERVER["DOCUMENT_ROOT"] (not set)

These variables _are_ set in CLI version of php5 and when executing php5-cgi by web server.

Reproduce code:
---------------
echo "<? phpinfo() ?>" > info.php
php5-cgi info.php > info.txt

Expected result:
----------------
_SERVER["PHP_SELF"] => info.php
_SERVER["SCRIPT_NAME"] => info.php
_SERVER["SCRIPT_FILENAME"] => info.php
_SERVER["PATH_TRANSLATED"] => info.php
_SERVER["DOCUMENT_ROOT"] =>
_SERVER["REQUEST_TIME"] => 1161331562
_SERVER["argv"] => Array
(
    [0] => info.php
)

_SERVER["argc"] => 1


in output

Actual result:
--------------
_SERVER["PHP_SELF"] => no value
_SERVER["REQUEST_TIME"] => 1161331600
_SERVER["argv"] => Array
_SERVER["argc"] => 1




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-20 09:22 UTC] konradg at irc dot pl
Better reproduce code:

<?

$vars = array ('PHP_SELF', 'SCRIPT_NAME', 'SCRIPT_FILENAME', 'PATH_TRANSLATED', 'DOCUMENT_ROOT');

foreach ($vars as $v) {
        echo '_SERVER["'.$v.'"] => '.(isset($_SERVER[$v]) ? $_SERVER[$v] : '(not set)');
        echo "\n";
}

?>

Expected result (from CLI version):
------------------------------------
php5 test.php
_SERVER["PHP_SELF"] => test.php
_SERVER["SCRIPT_NAME"] => test.php
_SERVER["SCRIPT_FILENAME"] => test.php
_SERVER["PATH_TRANSLATED"] => test.php
_SERVER["DOCUMENT_ROOT"] =>

Actual result (FASTCGI version):
---------------------------------
php5-cgi test.php
_SERVER["PHP_SELF"] =>
_SERVER["SCRIPT_NAME"] => (not set)
_SERVER["SCRIPT_FILENAME"] => (not set)
_SERVER["PATH_TRANSLATED"] => (not set)
_SERVER["DOCUMENT_ROOT"] => (not set)

Thanks.
 [2006-10-20 14:29 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Thos variables are populated by the web-server.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 07:01:32 2024 UTC