note 23428 modified in keyword.extends by danbrown

From: Date: Wed, 17 Jun 2009 19:09:43 +0000
Subject: note 23428 modified in keyword.extends by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157038@lists.php.net to get a copy of this message
Just to clarify something about inheritance. The following code : <?php class a { function call() { $this->toto(); } function toto() { echo('Toto of A'); } } class b extends a { function toto() { echo('Toto of B'); } } $b=new b; $b->call(); ?> ...will correctly display "toto of B" (that is, the function declared in the parent is correctly calling the redefined function in the child) --was-- Just to clarify something about inheritance. The following code : class a { function call() { $this->toto(); } function toto() { echo('Toto of A'); } } class b extends a { function toto() { echo('Toto of B'); } } $b=new b; $b->call(); ...will correctly display "toto of B" (that is, the function declared in the parent is correctly calling the redefined function in the child) http://php.net/manual/en/keyword.extends.php

« previous php.notes (#157038) next »