Searching...
Sunday, 14 October 2012

Php Overriding Example

10:25 pm

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

01 03 06 02 03a 04 05 7 8 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Click to see the code!
To insert emoticon you must added at least one space before the code.