#35722 [Opn->Bgs]: links troubles
| From: | derick@php.net | Date: | Sun, 18 Dec 2005 10:11:29 +0000 |
| Subject: | #35722 [Opn->Bgs]: links troubles | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-90610@lists.php.net to get a copy of this message | ||
ID: 35722
Updated by: derick@php.net
Reported By: zerkms at mail dot ru
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: independent
PHP Version: 5.1.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
There is nothing wrong here. In the first example you overwrite the
whole array with $a = array('a' => 'qwe'); and you're not just updating
the first element. This breaks the refererence (and it should do that).
In the second example you overwrite $a with $a = new stdclass();, but
as you assigned $q to $a by reference, $a and $q are simply the same
variable here. Hence modifying $a->s to 444 changes the s property for
$q too.
Previous Comments:
------------------------------------------------------------------------
[2005-12-18 04:43:30] zerkms at mail dot ru
Description:
------------
something strange with links to array and objects
Reproduce code:
---------------
//1st
$a = array('a' => 'zzzz');
$q =& $a['a'];
echo $q;
$a = array('a' => 'qwe');
echo $q;
//2nd
$a = new stdclass();
$a->s = 333;
$q =& $a;
echo $q->s;
$a = new stdclass();
$a->s = 444;
echo $q->s;
Expected result:
----------------
//1st
zzzzqwe
//2nd
333333
Actual result:
--------------
//1st
zzzzzzzz
//2nd
333444
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35722&edit=1