ID:               35722
 Updated by:       [EMAIL PROTECTED]
 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

Reply via email to