ID: 45145 User updated by: phpbug at thoria dot org Reported By: phpbug at thoria dot org -Status: Closed +Status: Bogus Bug Type: Variables related Operating System: Linux PHP Version: 5.2CVS-2008-06-01 (snap) New Comment:
------------------------------------------------------------------ Previous Comments: ------------------------------------------------------------------------ [2008-06-02 08:56:22] phpbug at thoria dot org Arrrhhh. I'm just guilty of C-thinking. ------------------------------------------------------------------------ [2008-06-02 08:34:19] phpbug at thoria dot org Now, I'm really scratching my head. After hacking my code down for hours, I realised it could be replicated in a few lines. Iteration 1 is OK. Iteration 2 produces the effect. The unset is not necessary. Iteration 3 shows how it goes away if $x='moo' is declared first. <?php echo "1<br>"; $y = "original string"; $x = "moo"; unset($x); $x = &$y; echo "X $x Y $y<br><br>"; echo "2<br>"; $y = "original string"; $x = "moo"; unset($x); $x = &$y; echo "X $x Y $y<br><br>"; echo "3<br>"; $x = "moo"; $y = "original string"; $x = &$y; echo "X $x Y $y<br><br>"; ?> ------------------------------------------------------------------------ [2008-06-01 14:35:37] phpbug at thoria dot org Description: ------------ On versions 5.2.3 and 4.3.1(Zend off), on different shared hosting servers. Within one large function/loop in my app $x = &$y; y is destroyed and replaced by x, intermittently. unset($x) is ignored if placed above it, and x still goes into y. There is no workaround, besides using $x = $y. I think any ref assignments in this loop behave like this if $x has had a prior value. You will need to have my whole app installed. It's so weird, it makes me feel dumb to submit it. Reproduce code: --------------- $bb = "original string"; $aa = "moo"; unset($aa); $aa = &$bb; echo "AA->$aa, BB->$bb <br>"; or $bb = "original string"; $aa = "moo"; $aa = &$bb; echo "AA->$aa, BB->$bb <br>"; The following is OK $aa = "moo"; $bb = "original string"; $aa = &$bb; echo "AA->$aa, BB->$bb <br>"; Expected result: ---------------- AA->original string, BB->original string AA->original string, BB->original string AA->original string, BB->original string Actual result: -------------- AA->original string, BB->original string AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->original string, BB->original string AA->moo, BB->moo AA->moo, BB->moo AA->original string, BB->original string AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->moo, BB->moo AA->original string, BB->original string AA->moo, BB-> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45145&edit=1
