ID: 22729
User updated by: andry at inbox dot ru
-Summary: Func-n script access behavior by sym.links to global
system arrays doesn't works
Reported By: andry at inbox dot ru
-Status: Bogus
+Status: Open
Bug Type: *General Issues
Operating System: WindowXP/5.1, FreeBSD 4.6-STABLE
PHP Version: 4.3.0, 4.2.2
New Comment:
<?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]";
}
// #ID0003
// 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>";*/
?>
//Look at http://hell-clan.h1.ru/php/debug/php-debugging.html
Previous Comments:
------------------------------------------------------------------------
[2003-03-15 20:45:42] [EMAIL PROTECTED]
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Hint: You've got a logic error in proc_test().
------------------------------------------------------------------------
[2003-03-15 09:49:10] andry at inbox dot ru
summary correcting
------------------------------------------------------------------------
[2003-03-15 09:40:45] andry at inbox dot ru
<?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 this bug report at http://bugs.php.net/?id=22729&edit=1