这样做的正确方法是什么:
// child
class B extends A {
function __construct() {
$this->object = new B; /// (or `new self` ?)
}
}
// parent
class A {
protected $object;
private static function {
$object = $this->object;
// use the new instance of $object
}
}
当我在代码中尝试此操作时,出现此错误:
Fatal error: Using $this when not in object context
我究竟做错了什么?(这是指类A
实例)