ID: 32786
User updated by: mcrusch at svm dot vetmed dot wisc dot edu
Reported By: mcrusch at svm dot vetmed dot wisc dot edu
Status: Open
Bug Type: Variables related
Operating System: Windows XP SP2
PHP Version: 4CVS-2005-04-20 (stable)
New Comment:
SuSE version is 9.1, sorry.
Previous Comments:
------------------------------------------------------------------------
[2005-04-20 23:52:08] mcrusch at svm dot vetmed dot wisc dot edu
Description:
------------
I called extract($array, EXTR_SKIP) in the global scope on an array and
one of the variables did not extract, even thought it was not set.
I traced the problem to a function call in which there was a global
statement involving the variable. This seems to have created the
variable in the global scope, but isset($var) (in the global scope) and
isset($GLOBALS["var"]) both return false. So, the variable is not set,
but it will not extract.
The only way to detect that it is in the symbol table is to do a
print_r($GLOBALS), which allows you to visually see that it is there,
but there is no way to programmatically detect it (other than capturing
the output of print_r and parsing it--ugly!)
Problem also occurs on a SuSE 9.3 Linux box (Linux kernel v.
2.6.5-7.147-smp) running PHP 4.3.9
Reproduce code:
---------------
$arrayOfStuff = array("stuff" => "valueOfStuff");
echo isset($stuff).", ".isset($GLOBALS["stuff"]).", $stuff\n";
// Commenting out the globalStuff() call produces the
// expected result
globalStuff();
extract($arrayOfStuff, EXTR_SKIP);
echo isset($stuff).", ".isset($GLOBALS["stuff"]).", $stuff\n";
function globalStuff() {
global $stuff;
}
Expected result:
----------------
, ,
1, 1, valueOfStuff
Actual result:
--------------
, ,
, ,
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32786&edit=1