note 70051 added to language.oop5.decon

From: Date: Sun, 01 Oct 2006 18:03:43 +0000
Subject: note 70051 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-117906@lists.php.net to get a copy of this message
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. ---- Server IP: 66.163.161.117 Probable Submitter: 86.1.146.242 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php Edit -- https://master.php.net/note/edit/70051 Del: integrated -- https://master.php.net/note/delete/70051/integrated Del: useless -- https://master.php.net/note/delete/70051/useless Del: bad code -- https://master.php.net/note/delete/70051/bad+code Del: spam -- https://master.php.net/note/delete/70051/spam Del: non-english -- https://master.php.net/note/delete/70051/non-english Del: in docs -- https://master.php.net/note/delete/70051/in+docs Del: other reasons-- https://master.php.net/note/delete/70051 Reject -- https://master.php.net/note/reject/70051 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117906) next »