note 69036 added to language.oop5.decon

From: Date: Mon, 21 Aug 2006 04:56:57 +0000
Subject: note 69036 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-116110@lists.php.net to get a copy of this message
Note that if a class contains another class, the contained class's destructor will be triggered after the destructor of the containing class. <?php class contained { protected $parent; public function __construct(&$p) { # $this->parent=&$p; } public function __destruct() { /* unset $this->parent */ print 'contained '; } } class containing { protected $contained; public function __construct() { $this->contained=new contained($this); } public function __destruct() { // unset($this->contained); print 'containing '; } } new containing(); ?> Will output containing contained After uncommenting the // comment, the output will change to contained containing Adding a reference from the contained class to the containing one (the # comment) will not change that, but beware, because it can cause random errors in other destructors in the parts of the script which seem unrelated! (PHP Version 5.1.2) ---- Server IP: 83.64.128.68 Probable Submitter: 83.15.56.98 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php Edit -- https://master.php.net/note/edit/69036 Del: integrated -- https://master.php.net/note/delete/69036/integrated Del: useless -- https://master.php.net/note/delete/69036/useless Del: bad code -- https://master.php.net/note/delete/69036/bad+code Del: spam -- https://master.php.net/note/delete/69036/spam Del: non-english -- https://master.php.net/note/delete/69036/non-english Del: in docs -- https://master.php.net/note/delete/69036/in+docs Del: other reasons-- https://master.php.net/note/delete/69036 Reject -- https://master.php.net/note/reject/69036 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116110) next »