Thinkphp5的前置方法列表.
作者:
ZSGZ_AD | 来源:发表于
2019-03-13 15:49 被阅读0次class Index extends \think\Controller
{
protected $beforeActionList =[ //前置方法列表,继承自Controller
'before1' => '', //为空,表示before是当期类中的全部操作的前置操作
'before2' => ['only'=>'demo2'], //only仅适用
'before3' => ['except'=>'demo1,demo2'],//except排除
];
protected $siteName ='默认值'; //自定义属性
protected function before1(){
$this->siteName = $this->request->param('name'); //获取url中访问的name值;
}
protected function before2(){
$this->siteName = '口袋里的';
}
protected function before3(){
$this->siteName = '创新高低,大湖名城~';
}
public function demo1()
{
return $this->siteName;
}
public function demo2()
{
return $this->siteName;
}
public function demo3()
{
return $this->siteName;
}
}
![](https://img.haomeiwen.com/i7044412/4b969ced94a5f651.png)
image.png
![](https://img.haomeiwen.com/i7044412/ee132179df2e054d.png)
image.png
![](https://img.haomeiwen.com/i7044412/426af16d3f3b1bd8.png)
image.png
本文标题:Thinkphp5的前置方法列表.
本文链接:https://www.haomeiwen.com/subject/zihtmqtx.html
网友评论