note 11822 deleted from language.references.unset by cece
| From: | cece@php.net | Date: | Mon, 18 Aug 2003 11:11:35 +0000 |
| Subject: | note 11822 deleted from language.references.unset by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54576@lists.php.net to get a copy of this message | ||
Note Submitter: aulbach@unter.franken.de
----
I will also mention the following case, which describes a compatibility problem from PHP3 to PHP4.
In PHP3 this works all as "expected".
I described this "bug" also in bug id # 8937.
Withing PHP4 (have to rewrite many scripts from PHP3 to PHP4) you can solve this problem only by
replacing $x with $GLOBALS['x'] - I found no other way.
<?
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);
?>