php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25418 references on unset vars continue to live
Submitted: 2003-09-07 13:57 UTC Modified: 2003-09-07 16:07 UTC
From: alexandre dot boyer7 at wanadoo dot fr Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-09-07 (dev) OS: WIN 2000
Private report: No CVE-ID: None
 [2003-09-07 13:57 UTC] alexandre dot boyer7 at wanadoo dot fr
Description:
------------
just look at the source code

Reproduce code:
---------------
http://cedalex.phpnet.org/test.html

Expected result:
----------------
Create And Print A1
a Object ( [id] => 914581 ) 

A2 references A1; ref=1
A3 reference A2; ref=1
A1 unset; print A1 

A1 unset; print A2 

A1 unset; print A3 



Actual result:
--------------
Create And Print A1
a Object ( [id] => 914581 ) 

A2 references A1; ref=1
A3 reference A2; ref=1
A1 unset; print A1 

A1 unset; print A2 
a Object ( [id] => 914581 ) 
A1 unset; print A3 
a Object ( [id] => 914581 ) 

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-07 14:00 UTC] derick@php.net
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

If you unset() something, you remove the link from the variable name to the value. All other references still exist, because the variable name is not the same as the one you unset().

Derick
 [2003-09-07 16:07 UTC] alexandre dot boyer7 at wanadoo dot fr
I read the doc and i understood the results return, but i don't know how todispose an object that is referenced by several references. For example,

if i have 3 references that reference an object in an array, how can i dispose the object in that array (set it to null) with one of my references ? 

For the moment, i use singleton to achieve it but it's heavy. I think a free() or dispose() function is needed which destroys an object and set all references to null;needn't it ?

Regards,
AB
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Aug 15 22:01:28 2024 UTC