From:             mz dot evgeny at gmail dot com
Operating system: Any
PHP version:      5.5.5RC1
Package:          Variables related
Bug Type:         Bug
Bug description:Referenced variables override value of a reference-variable to 
an object

Description:
------------
This happens when I try to re-use a variable that was used to hold a
reference to another variable for holding an object reference. 
If I remove the second line or use unset, it works as expected. But
AFAIK it's not required to unset variables before assigning it a new
value.

Test script:
---------------
$num = 123;
$ref = &$num; 

$obj = new stdClass();
$ref = $obj; 
$num = 321;
var_dump($ref);

Expected result:
----------------
class stdClass#1 (0) {
}

Actual result:
--------------
int(321)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65831&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65831&r=trysnapshot54
Try a snapshot (PHP 5.5):   
https://bugs.php.net/fix.php?id=65831&r=trysnapshot55
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65831&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65831&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65831&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65831&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65831&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65831&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65831&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65831&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65831&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65831&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65831&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65831&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65831&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65831&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65831&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65831&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65831&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65831&r=mysqlcfg

Reply via email to