超类:
是PHP的一个特殊类
超类就是定义了一些通用的方法,在其他类中不需要继承就可以直接使用的超类的方法,而是通过use引入的类,相当于include这样理解
在框架中使用的这几个方法其实都是属于超类里边的方法
在框架中使用的这几个方法其实都是属于超类里边的方法
$this->success($msg,$url); $this->error($msg,$url); $this->result($data,$code,$msg,$type); $this->redirect($url,$param);
超类的用法:
/** * 用法: * class index * { * use \traits\controller\Jump; * public function index(){ * $this->error(); * $this->redirect(); * } * } */
案例:
就拿我们的controller这个类来说引入的Jump这个超类,我们才可以在控制器使用文章开头的那四个方法的