class
B
extends
A {
public
function
__construct() {
parent::__construct();
}
}
这里的 parent::_construct()是子类将 calling scope 转化为父类 A 的 calling scope。这个并不是
静态调用。
回到最上面的例子
myClass::getName();
这个时候由于没有使用 parent 这样的关键字,也没有对
$this
重新赋值,因此 calling scope
并没有改变,仍然是
$app
。就是说这个时候,所有出现的
$this
指针都是指向
$app
的。