PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Tue May 02, 2006 11:29 am
Code: Select all
<?php
class foo {
function zim() {
echo 'foo';
}
}
class bar extends foo {
function zim() {
echo 'bar';
}
}
$a = new bar();
$a->zim();
?>
I'm hoping that this code outputs 'bar' in PHP 4. It certainly does in PHP 5 but I don't want to have to install it just to try.
Can anyone tell me?
The manual seems to be somewhat incomplete on the issue of PHP 4 inhertiance and function overriding.
Thanks
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Tue May 02, 2006 11:35 am
Yes, methods override methods of the same name in the parent class in PHP4.
(#10850)