Hierarchical Inheritance

In hierarchical type of inheritance, one class is extended by many subclasses. It is one-to-many relationship

Example

<?php
class a
{
public function function_a(){
echo “class A”;
}
}

class b extends a
{
public function function_b(){
echo “class B”;
}
}

class c extends a
{
public function function_c(){
echo “class c”;
}
}

echo c::function_c();
echo c::function_a();

?>

Share