Exemplo n.º 1
0
<?php

class MyObject
{
    function myMethod()
    {
        echo "Standard Functionality\n";
    }
}
class MyOtherObject extends MyObject
{
    function myMethod()
    {
        echo "New Functionality";
        parent::myMethod();
    }
}
$obj = new MyOtherObject();
$obj->myMethod();
Exemplo n.º 2
0
<?php

class MyObject
{
    static function myMethod()
    {
        static::myOtherMethod();
    }
    static function myOtherMethod()
    {
        echo "called from MyObject";
    }
}
class MyOtherObject extends MyObject
{
    static function myOtherMethod()
    {
        echo 'called from MyOtherObject';
    }
}
MyOtherObject::myMethod();
Exemplo n.º 3
0
<?php

class MyObject
{
    function myBaseMethod()
    {
        echo "I am declared in MyObject\n";
    }
}
class MyOtherObject extends MyObject
{
    function myExtendedMethod()
    {
        echo "myExtendedMethod is declared in MyOtherObject\n";
        self::myBaseMethod();
    }
}
$object = new MyOtherObject();
$object->myExtendedMethod();