note 24441 modified in keyword.extends by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Jun 2009 19:08:48 +0000 |
| Subject: | note 24441 modified in keyword.extends by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157037@lists.php.net to get a copy of this message | ||
This prints out 'ab'. No need to create a new instance of a, therefor both methods still
exists with same name.
<?php
class a {
function samename(){
echo 'a';
}
}
class b extends a{
function samename(){
echo 'b';
}
function b(){
a::samename();
b::samename();
}
}
$test_obj = new b();
?>
--was--
class a {
function samename(){
echo 'a';
} }
class b extends a{
function samename(){
echo 'b';
}
function b(){
a::samename();
b::samename();
} }
$test_obj = new b();
Quiet confusing though, as this prints out 'ab'.
No need to create a new instance of a,
therefor both methods still exists with same name.
http://php.net/manual/en/keyword.extends.php