note 11822 added to language.references.unset.php

From: Date: Thu, 08 Mar 2001 17:32:06 +0000
Subject: note 11822 added to language.references.unset.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12042@lists.php.net to get a copy of this message
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'&lt;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 "&lt;br>"; unset($x); test2($dir); echo "DIR called with function test2(): "; print_r($x); ?> http://www.php.net/manual/en/language.references.unset.php

« previous php.notes (#12042) next »