note 69036 deleted from language.oop5.decon by cmb

From: Date: Sun, 08 Sep 2019 10:25:18 +0000
Subject: note 69036 deleted from language.oop5.decon by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212137@lists.php.net to get a copy of this message
Note Submitter: chanibal at deltasoft dot int dot pl dot SPAMPROTECT ---- 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)

« previous php.notes (#212137) next »