note 17268 added to keyword.extends

From: Date: Sun, 02 Dec 2001 16:46:05 +0000
Subject: note 17268 added to keyword.extends
Groups: php.notes 
Request: Send a blank email to php-notes+get-21533@lists.php.net to get a copy of this message
In a previous version of the documentation it was explicetely mentioned, but not anymore. If you extend a class, which has an initialisation function, you need to call that function explicetely in the extension, or it will not be handled. Even if you call the extension, from the original itself, to create child objects. IE: <?php class A { var $cs, $b; function A { $this->cs=mysql_connect(); mysql_select_db("mydb", $this->cs); } function make_b_child { $this->b=new B; } } class B extends A { function B { $this->A(); //without this line everything fails. mysql_query("SELECT COUNT(*) AS total FROM my_table", $this->cs); } } -- http://www.php.net/manual/en/keyword.extends.php http://master.php.net/manage/user-notes.php?action=edit+17268 http://master.php.net/manage/user-notes.php?action=delete+17268 http://master.php.net/manage/user-notes.php?action=reject+17268

« previous php.notes (#21533) next »