From: andry at inbox dot ru
Operating system: WindowXP/5.1, FreeBSD 4.6-STABLE
PHP version: 4.3.0
PHP Bug Type: *General Issues
Bug description: Func-n script access behavior by sym.links to global system arrays
isn't works
<?php
header("Content-Type: text/html; charset=windows-1251");
header("X-Powered-By: PHP 4.3.0");
header("Pragma: no-cache");
echo "<?xml version=\"1.0\" encoding=\"windows-1251\" ?>"
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Language" content="en" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"
/>
<meta http-equiv="Resource-Type" content="php script for debugging" />
<meta http-equiv="Expires" content="Thu, Jan 1 1970 00:00:01 GMT" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Distribution" content="local" /></head>
<?php
$sBehavior = array("<strong><span
style=\"color:#00ff00;background-color:#e8f5e8;\">SET</span></strong>",
"<strong><span
style=\"color:#ff0000;background-color:#f5e8e8;\">NOT
set</span></strong>");
function proc_test($dNames)
{
// #ID0002
// Without this declaration, script doesn't works,
// because i think that $sBehavior doesn't expecting in this area of
code,
// and #ID0001-code never executed!
global $sBehavior;
if(!isset($dNames))
// #ID0001
// Never executed for the unknown reason, if #ID0002 block of code is
commented.
// I have had suspecting, that is dNames exists, but always empty.
echo "<strong>dNames</strong> global system arrays enumerator doesn't
exist!";
else
foreach($dNames as $sValue)
{
if(isset($bIndent)) echo "<br />";
else $bIndent = true;
if(isset($$sValue)) echo "<strong>$sValue</strong> is
$sBehavior[0]";
else echo "<strong>$sValue</strong> is $sBehavior[1]";
}
}
$dNames = array('GLOBALS', '_SERVER', '_FILES', '_ENV', '_COOKIE', '_GET',
'_POST');
echo "<h4>This is script has been tested under"
. " [PHP Version 4.3.0 (NOT module), Apache/2.0.43 Server at localhost
Port 80,"
. " WindowXP/5.1 Build 2600.xpsp1.020828-1920]"
. " and [PHP Version 4.2.2, Apache/1.3.26 (Unix) rus/PL30.15,"
. " FreeBSD 4.6-STABLE #12 Build Jul 24 2002 15:29:54]"
. "<br />This is script works correctly there is the global system
arrays is works too.</h4><hr>";
echo "<em>Function/procedure behavior with global system arrays
enumerator.</em><br />";
proc_test($dNames);
echo "<br /><hr /><em>Global behavior with global system arrays
enumerator.</em><br />";
foreach($dNames as $sValue)
{
if(isset($bIndent)) echo "<br />";
else $bIndent = true;
if(isset($$sValue)) echo "<strong>$sValue</strong> is $sBehavior[0]";
else echo "<strong>$sValue</strong> is $sBehavior[1]";
}
// Without this is block of code, full script has suspicious behavior.
// This is VERY strange.
// Uncomment this is block of code and review the results!
/*echo "<br /><hr /><em>Global behavior with static access.</em><br />";
if(isset($GLOBALS)) echo "<strong>GLOBALS</strong> is $sBehavior[0]";
else echo "<strong>GLOBALS</strong> is $sBehavior[1]";
echo "<br />";
if(isset($_SERVER)) echo "<strong>_SERVER</strong> is $sBehavior[0]";
else echo "<strong>_SERVER</strong> is $sBehavior[1]";
echo "<br />";
if(isset($_FILES)) echo "<strong>_FILES</strong> is $sBehavior[0]";
else echo "<strong>_FILES</strong> is $sBehavior[1]";
echo "<br />";
if(isset($_ENV)) echo "<strong>_ENV</strong> is $sBehavior[0]";
else echo "<strong>_ENV</strong> is $sBehavior[1]";
echo "<br />";
if(isset($_COOKIE)) echo "<strong>_COOKIE</strong> is $sBehavior[0]";
else echo "<strong>_COOKIE</strong> is $sBehavior[1]";
echo "<br />";
if(isset($_GET)) echo "<strong>_GET</strong> is $sBehavior[0]";
else echo "<strong>_GET</strong> is $sBehavior[1]";
echo "<br />";
if(isset($_POST)) echo "<strong>_POST</strong> is $sBehavior[0]";
else echo "<strong>_POST</strong> is $sBehavior[1]";*/
echo "<br /><hr /><br /><u>Please, research the source.</u>";
?>
--
Edit bug report at http://bugs.php.net/?id=22729&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22729&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22729&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22729&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22729&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22729&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22729&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22729&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22729&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22729&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22729&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22729&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22729&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22729&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22729&r=gnused