#36971 [Com]: unset() no longer works on $this in PHP5

From: Date: Thu, 06 Jul 2006 15:41:19 +0000
Subject: #36971 [Com]: unset() no longer works on $this in PHP5
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969373467@lists.php.net to get a copy of this message
ID: 36971 Comment by: keko_metal at hotmail dot com Reported By: k at phpkoala dot com Status: Open Bug Type: Documentation problem Operating System: Linux PHP Version: 5.1.2 New Comment: Scott, do you really think that $object->im_done_please_kill_me() is an absurd idea? Previous Comments: ------------------------------------------------------------------------ [2006-06-18 19:21:40] henke dot andersson at comhem dot se In php5 no php variable actualy contains the object instances, they contains pointers to instances. Thats why unseting the $this variable does nothing. Just because you stop knowing where it is doesn't mean it ceases to exist. And the $this variable is a special case. It would not make sence to unset it. As far as I can understand, $this shouldn't even affect the garbage collection, if it did(and php doesn't adjust for recurive pointers) the garbage collection would never destroy objects instances! ------------------------------------------------------------------------ [2006-05-04 10:31:02] gixxman at gmali dot com class FalseClass { public function __destruct() { echo "Gonna die, man"; } } $f = new FalseClass; unset($f); RESULTS: Gonna die, man ------------------------------------------------------------------------ [2006-04-05 19:04:17] k at phpkoala dot com Thanks Scott, that makes sense. Does that mean there is no way to accomplish this in PHP5? I guess so. I'd like to see this added to the docs. ------------------------------------------------------------------------ [2006-04-05 06:21:38] derick@php.net @Scott: totally true. This can ofcourse be mentioned in the documentation if it's not already there... ------------------------------------------------------------------------ [2006-04-04 23:53:40] scottmacvicar at ntlworld dot com Destroying an object internally is an absurd concept, how can you destroy something that is currently in the scope of execution? The reason it works in PHP 4 and not in PHP 5 is that object types are no longer mutable. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/36971 -- Edit this bug report at http://bugs.php.net/?id=36971&edit=1

« previous php.doc (#969373467) next »