Php Overriding
Php Overriding :
the
same member functions defined in the parent class and also in the sub-class is
called as overriding member function.
Parent: is
a keyword of php that can be used inside a subclass member function and will be
acting as a reference of a parent class in subclass.
Php Overriding Example:
<?php
class
A{
function display(){
echo "inside class
A<br>";
}
}
class
B extends A{
function display() {
echo "inside class
B<br>";
parent::display();
}
}
?>
<h1>
<?php
$obj = new B();
$obj->display();
?>
</h1>
OutPut:
inside class B
inside class A
0 comments:
Post a Comment