php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22729 GLOBALS is set and is not set in the same time
Submitted: 2003-03-15 09:40 UTC Modified: 2003-03-26 13:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: andry at inbox dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.0, 4.2.2 OS: WindowXP/5.1, FreeBSD 4.6-STABLE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andry at inbox dot ru
New email:
PHP Version: OS:

 

 [2003-03-15 09:40 UTC] 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>";

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-15 09:49 UTC] andry at inbox dot ru
summary correcting
 [2003-03-15 20:45 UTC] pollita@php.net
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-26 13:24 UTC] sniper@php.net
Provide SHORT example script, MAXIMUM of 20 lines.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Aug 15 18:00:02 2025 UTC