Ejemplo n.º 1
0
    {
        echo h(parent::CONST_VALUE) . ',';
        echo h(self::CONST_VALUE) . ',';
        echo h(static::CONST_VALUE) . '<br>';
    }
}
// Secondクラスを継承したThirdクラスを定義する
class Third extends Second
{
    const CONST_VALUE = 'third';
    // 親クラスのshow()メソッドを呼び出す
    public function show()
    {
        parent::show();
    }
}
echo '<p>';
echo 'Secondクラスのshow()メソッドを呼び出す:' . '<br>';
$second = new Second();
$second->show();
echo '</p>';
echo '<p>';
echo 'thirdクラスのshow()メソッドを呼び出す:' . '<br>';
$third = new Third();
$third->show();
echo '</p>';
?>
</body>
</html>

Ejemplo n.º 2
0
    }
    public function displayText()
    {
        echo $this->text;
    }
    public static function say()
    {
        echo self::$silence;
    }
}
class Second extends First
{
    public function displayText()
    {
        echo 'second ' . $this->text . '<br />';
        parent::displayText();
    }
}
class Third extends Second
{
}
echo First::$silence;
First::$silence = 'ooooo';
echo First::$silence;
echo Second::$silence;
Third::say();
// $first = new First();
// $first->text = 'world';
// $first->displayText();
// $second = new Second('asdfasdfljkqw qwer qlwejrqwer');
// $second->displayText();