Ejemplo n.º 1
0
class Glass
{
}
class redGlass extends Glass
{
    public function display()
    {
        echo "发射红光<br/>";
    }
}
class blueGlass extends Glass
{
    public function display()
    {
        echo "发射蓝光<br/>";
    }
}
class Pig
{
    public function display()
    {
        echo "猪八戒<br/>";
    }
}
$light = new Light();
$red = new redGlass();
$blue = new blueGlass();
$pig = new Pig();
$light->ons($red);
$light->ons($blue);
//$light->ons($pig);