<?php
class father
{
public function __construct()
{
$this->init();
}
private function init()
{
echo "father\n";
}
}
class son extends father
{
public function init()
{
echo "son\n";
}
}
$son = new son();
因为son里的init方法是public,而father的init方法是private,这个其实表示你son里的init方法并没有重写父类里的方法。那自然调用的仍然是父类自己的实现了