Polymorphism in OOP
Posted by Raj
Polymorphism in OOP:
In this tutorial we will study about polymorphism.
- Polymorphism in PHP5 : To allow a class member to perform diffrent tasks.
- polymorphism where the function to be called is detected based on the class object calling it at runtime.
Example:
< ?
class Person
{
public function Talk()
{
echo "English";
}
}
class Language extends Person
{
public function Talk()
{
echo "French";
}
}
function CallMethod(Person $p)
{
$p->Talk();
}
$l = new Language();
CallMethod($l);
?>
Output:
French;
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
OOP interview questions and answers,
oops in php5,
PHP,
PHP interview questions and answers,
php programming,
php scripts,
php training,
php tutorial,
php5,
Polymorphism,
Polymorphism in oop
.You can leave a response, or trackback from your own site.