我尝试使用父类的名称作为构造函数,它对我部分地起作用。
首先调用
"DarthVader方法"
就像构造函数一样,但从未调用
"LukeSkywalker构造函数"。
有人知道怎么做吗?
例子:
Darth.php
class DarthVader{
public function DarthVader(){
echo "-- Obi-Wan never told you what happened to your father.\n";
}
public function reponse(){
echo "-- No. I am your father\n";
}
}
Luke.php
include("Darth.php")
class LukeSkywalker extends DarthVader{
public function __constructor(){
echo "- He told me enough! He told me you killed him!\n"
$this->response();
}
}
预期结果:
欧比旺没有告诉你有关你父亲的事情。
他告诉了我足够多!他告诉我是你杀了他!
不。我是你的父亲。
我真的很希望它可以自动完成。