author:咔咔

wechat:fangkangfk

 

超类:

是PHP的一个特殊类

超类就是定义了一些通用的方法,在其他类中不需要继承就可以直接使用的超类的方法,而是通过use引入的类,相当于include这样理解

 

在框架中使用的这几个方法其实都是属于超类里边的方法

$this->success($msg,$url);

$this->error($msg,$url);

$this->result($data,$code,$msg,$type);

$this->redirect($url,$param);

超类对应的提示模板位置

【TP5.1】超类解释

 

超类的位置

【TP5.1】超类解释

超类的用法:


/**
 * 用法:
 * class index
 * {
 *     use \traits\controller\Jump;
 *     public function index(){
 *         $this->error();
 *         $this->redirect();
 *     }
 * }
 */

 

案例:

就拿我们的controller这个类来说引入的Jump这个超类,我们才可以在控制器使用文章开头的那四个方法的

【TP5.1】超类解释

相关文章:

  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-12-07
  • 2021-07-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2021-06-21
  • 2022-02-20
  • 2022-01-03
  • 2021-05-29
相关资源
相似解决方案