|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-01-26 10:25 UTC] aulbach at unter dot franken dot de
unset() in context with GLOBAL has a serious bug. This bug appeard,
when I changed a PHP3-program to PHP4. The problem is now,
that constructs like the following are several times in this old program.
Sorry, I haven't checked, if this problem is fixed in 4.0.4. If so, perhaps someone can tell me? TIA.
Think this problem depends Zend, cause ZEND_CHANGES tells me:
"unset() is no longer a function, but a statement. It was never
documented as a function so the impact should be no bigger than nada."
I have made a test-case:
<?
function test1 ($dir) {
GLOBAL $x;
unset($x);
$x[$dir]=true;
mydirname($dir);
}
function test2 ($dir) {
GLOBAL $x;
####### unset($x); no unset!
$x[$dir]=true;
mydirname($dir);
}
function mydirname ($dir) {
GLOBAL $x;
$dir=ereg_Replace('/[^/]*$','',$dir);
if (!empty($dir)) {
echo "'$dir'<br>"; flush();
mydirname($dir);
$x[$dir]=true;
}
}
$dir="/hugo/bla/fasel/test"; # first char must be '/' !
unset($x);
test1($dir);
echo "DIRS called with function test1(): "; print_r($x);
echo "<br>";
unset($x);
test2($dir);
echo "DIRS called with function test2(): "; print_r($x);
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 07:00:01 2025 UTC |
The mentioned workarround (unset($GLOBALS['x'])) dosn't work with my testscript. The result is exactly the same as with the first version of my script. I really have GREAT TROUBLES to upgrade this old application to PHP4. Result: '/hugo/bla/fasel' '/hugo/bla' '/hugo' DIR called with function test1(): Array ( [/hugo] => 1 [/hugo/bla] => 1 [/hugo/bla/fasel] => 1 ) '/hugo/bla/fasel' '/hugo/bla' '/hugo' DIR called with function test2(): Array ( [/hugo/bla/fasel/test] => 1 [/hugo] => 1 [/hugo/bla] => 1 [/hugo/bla/fasel] => 1 ) Script: <? function test1 ($dir) { GLOBAL $x; unset($GLOBALS["x"]); $x[$dir]=true; mydirname($dir); } function test2 ($dir) { GLOBAL $x; ####### unset($x); no unset! $x[$dir]=true; mydirname($dir); } function mydirname ($dir) { GLOBAL $x; $dir=ereg_Replace('/[^/]*$','',$dir); if (!empty($dir)) { echo "'$dir'<br>"; flush(); mydirname($dir); $x[$dir]=true; } } $dir="/hugo/bla/fasel/test"; # first char must be '/' ! unset($x); test1($dir); echo "DIR called with function test1(): "; print_r($x); echo "<br>"; unset($x); test2($dir); echo "DIR called with function test2(): "; print_r($x); ?>