note 25892 deleted from language.oop by didou

From: Date: Sun, 07 Dec 2003 02:39:32 +0000
Subject: note 25892 deleted from language.oop by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-61547@lists.php.net to get a copy of this message
Note Submitter: skynet@context-ua.com ---- [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 ]

« previous php.notes (#61547) next »