丑陋的解决方法是将一个布尔参数传递给Papa,指示您不希望解析其构造函数中包含的代码。即:
// main class that everything inheritsclass Grandpa { public function __construct() { }}class Papa extends Grandpa{ public function __construct($bypass = false) { // only perform actions inside if not bypassing if (!$bypass) { } // call Grandpa's constructor parent::__construct(); }}class Kiddo extends Papa{ public function __construct() { $bypassPapa = true; parent::__construct($bypassPapa); }}


