#49962 [NEW]: Reassign an object inside function
| From: | diego at ditech dot com dot br | Date: | Thu, 22 Oct 2009 18:16:18 +0000 |
| Subject: | #49962 [NEW]: Reassign an object inside function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-143806@lists.php.net to get a copy of this message | ||
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