Esempio n. 1
0
    {
        return 'Take this 500 $';
    }
}
class Elder extends Father
{
    public function myEarning()
    {
        echo "Father told me " . parent::pocketMoney();
    }
}
class Younger extends Father
{
    public function myEarning()
    {
        echo "Father told me " . parent::pocketMoney();
    }
}
class son extends Younger
{
    public function mysonclass()
    {
        echo 'this is son class->' . parent::pocketMoney() . '<-son class end';
    }
}
$son = new son();
$son->mysonclass();
//$elder = new Elder();
//$elder->myEarning();  // output Father told me Take this 500 $
//$younger = new Younger();
//$younger->myEarning();  // output Father told me Take this 500 $
    public function sayMyName()
    {
        echo "father";
        $this->sayPrivate();
    }
    protected function sayPrivate()
    {
        echo "father private function";
    }
}
class son extends father
{
    public $num = 7788;
    public function __construct()
    {
        parent::__construct();
    }
    public function sayMyName()
    {
        echo "son";
    }
    protected function sayPrivate()
    {
        echo "son private function";
    }
}
$son = new son();
echo $son->getNum();
$son->setNum(6655);
echo $son->getNum();
//echo 'somdsa';