php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44175 unable to unset reference
Submitted: 2008-02-19 18:12 UTC Modified: 2008-02-19 18:15 UTC
From: absynthe dot is at free dot fr Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.5 OS: linux
Private report: No CVE-ID: None
 [2008-02-19 18:12 UTC] absynthe dot is at free dot fr
Description:
------------
Hello,

First of all I would like to know if one day we will be able to unset $this into a class in order to destroy the object. It could really be useful to prevent big memory usage.

As it can't be done I tried to unset an object by unsetting a reference  of this object but it has no effect on the object but only on the reference.

Should unset destroy the reference itself and the object ???

if you don't think so can you think of something different to destroy both of them like I don't know, destroy($obejctsreference)

Regards.

Reproduce code:
---------------
<?

$x = new stdClass();
$x->a = 'ayayaye';

$b[0] =& $x;

unset($b[0]);

var_dump($x);

?>

Expected result:
----------------
NULL

Actual result:
--------------
object(stdClass)#1 (1) {
  ["a"]=>
  string(7) "ayayaye"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-19 18:15 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC