Controller中父类如何调用子类方法

浏览:4298 发布日期:2014/02/08 分类:求助交流
写了一个CommController包含一些公共操作逻辑,
被childrenController继承class CommController{
public function add(){
        if(IS_POST){
            $this->save();
        }
        else{
//不是官方手册里的_before_add
            if(method_exists($this,'befor_add')){
                $this->befor_add($data);
            }
            $this->display();
        }
    }
}
childrenController extends CommController{
function before_add(){
    echo '我存在!';
}
}
现访问childrenController的add方法,没有输出,求解。
如果去掉这句if(method_exists($this,'befor_add'))会直接报错,不存在before_add方法。
最佳答案
评论( 相关
后面还有条评论,点击查看>>