|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-20 23:54 UTC] mcrusch at svm dot vetmed dot wisc dot edu
[2005-04-21 00:21 UTC] sniper@php.net
[2005-04-21 00:31 UTC] mcrusch at svm dot vetmed dot wisc dot edu
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 03:00:02 2025 UTC |
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: -------------- , , , ,