Exemplo n.º 1
0
    public $age;
    static $money = 100000;
    public function __construct()
    {
        parent::__construct();
        // 调用父类构造方法
        echo '这里是子类', PHP_EOL;
    }
    public function say()
    {
        parent::say();
        // 调用父类中的方法
        echo $this->name, "\tis\t", $this->gender, ",and is\t", $this->age, PHP_EOL;
    }
    public function cry()
    {
        echo parent::$money, PHP_EOL;
        echo '%>_<%', PHP_EOL;
        echo self::$money, PHP_EOL;
        // 调用自身构造方法
        echo '(*^_^*)';
    }
}
$poor = new family();
echo '<br>';
$poor->name = 'Lee';
$poor->gender = 'female';
$poor->age = 25;
$poor->say();
echo '<br>';
$poor->cry();