note 25892 added to language.oop

From: Date: Thu, 10 Oct 2002 08:35:16 +0000
Subject: note 25892 added to language.oop
Groups: php.notes 
Request: Send a blank email to php-notes+get-37881@lists.php.net to get a copy of this message
[Note: here is a trick with inheritance. Consider we have object named 'b' that extends object 'a'. But we would like to call a function 'b::handle' right from object 'a'. The following code will do the trick.] <?php class a { function a (){ echo "Class a construct<br>"; } function handle() { echo "Class a handle<br>"; } function proceed() { $this->handle(); //actually b::handle is called here; echo "Class a proceed<br>"; } } class b extends a { function b (){ parent::a(); echo "Class b construct<br>"; } function handle(){ echo "Class b handle<br>"; parent::handle(); } } $varriable = new b(); $varriable->proceed(); ?> [Output: Class a construct Class b construct Class b handle Class a handle Class a proceed ] -- http://www.php.net/manual/en/language.oop.php http://master.php.net/manage/user-notes.php?action=edit+25892 http://master.php.net/manage/user-notes.php?action=delete+25892 http://master.php.net/manage/user-notes.php?action=reject+25892

« previous php.notes (#37881) next »