note 70051 deleted from language.oop5.decon by cmb

From: Date: Sun, 08 Sep 2019 10:27:03 +0000
Subject: note 70051 deleted from language.oop5.decon by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212140@lists.php.net to get a copy of this message
Note Submitter: ---- This is a simple thing to bear in mind but it's also easy to forget it. When chaining object constructors and destructors, always remember to call the superclass __construct() method in the subclass __construct() so that all superclass members are properly initialized before you start initializing the ones belonging to your subclass. Also, you will usually want to do your own cleanup first in your subclass __destruct() method so you will probably want to call the superclass __destruct() as the last thing in your subclass so that you can use resources defined in the superclass during the cleanup phase. For example, if your superclass includes a database connection and your subclass __destruct method commits things to the database then if you call the superclass destruct before doing so then the database connection will no longer be valid and you will be unable to commit your changes.

« previous php.notes (#212140) next »