From:             diego at ditech dot com dot br
Operating system: Windows XP SP3
PHP version:      5.2.11
PHP Bug Type:     Class/Object related
Bug description:  Reassign an object inside function

Description:
------------
When trying to reassign an object inside a function, it is not acting as
passed by reference.

Reproduce code:
---------------
<?php
class foo {
}

function change($obj) {
  $obj = null;
}

function change_ref(&$obj) {
  $obj = null;
}

$o = new foo;

change($o);
var_dump($o);

change_ref($o);
var_dump($o);

Expected result:
----------------
Both should yield the same result.

1st: NULL
2nd: NULL

Actual result:
--------------
Only change_ref is redefining the object.

1st: 
object(foo)#1 (0) {
}

2nd: NULL

-- 
Edit bug report at http://bugs.php.net/?id=49962&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49962&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49962&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49962&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49962&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49962&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49962&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49962&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49962&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49962&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49962&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49962&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49962&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49962&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49962&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49962&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49962&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49962&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49962&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49962&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49962&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49962&r=mysqlcfg

Reply via email to