如何从超类构造函数调用子类方法?
示例子类:
<?php
include('../classes/A.php');
class B extends A {
public function __construct()
{
parent::__construct($this->view);
}
public function view() {
//something
}
}
$b = new B;
?>
示例超类:
<?php
abstract class A
{
private $callback;
public function __construct($callback)
{
$this->callback = $callback;
call_user_func($this->callback);
}
}
?>
我该怎么做才能让它发挥作用?