Calling a function from the parent class
| From: | Eli | Date: | Tue, 15 Mar 2005 23:06:30 +0000 |
| Subject: | Calling a function from the parent class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-210856@lists.php.net to get a copy of this message | ||
Hi,
<?php
class A
{
public function func() { echo "A"; }
}
class B extends A
{
public function func() { echo "B"; }
}
$cls=new B();
$cls->func(); //echo: B
?>
How can I call func() of class A from $cls object (that when I call func() it will echo "A" and not "B")?
Changing functions names or declaring another function in class B that will call parent::func() are not good for me.
-thanks, Eli