parent::mymethod() call $this->mymethod() bug?
| From: | Jean-Pierre Arneodo | Date: | Fri, 21 Sep 2001 13:15:30 +0000 |
| Subject: | parent::mymethod() call $this->mymethod() bug? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-68144@lists.php.net to get a copy of this message | ||
Hi!
something looks strange for me.
Why the method Fils::x is called?
MyConfig: RH7.1 PHP4.0.6
I found something similar in the bug database.
http://bugs.php.net/index.php?id=12313
Open 4.0.6 Linux parent resolving and deep require's
## RESULT
Fils::Fils called
Pere::Pere called
Fils::x called
Pere::x called
## SOURCE
class Pere {
function Pere(){
echo "<br>Pere::Pere called";
}
function x(){
echo "<br>Pere::x called";
}
}
class Fils extends Pere {
function Fils(){
echo "<br>Fils::Fils called";
$this->Pere();
}
function x(){
echo "<br>Fils::x called";
parent::x();
}
function y(){
parent::x();
}
}
$f = new Fils();
$f->x();
___________________________________________________________
Do You Yahoo!? -- Un e-mail gratuit @yahoo.fr !
Yahoo! Courrier : http://fr.mail.yahoo.com