网址:http://localhost/thinkphp/public/index/Be/demo1/name/think
——————————————————————————————
namespace app\index\controller;
class Be extends \think\Controller
{
protected $beforeActionList = [
//这里是前置方法
'before1' => '',
// 'before2'=>['only'=>'demo2'],
//'before3'=>['except'=>'demo3,demo1'],
];
protected $siteName;
//这里写个前置方法
protected function before1()
{
$this->siteName =$this->request->param('name');
}
protected function before2()
{
$this->siteName = '百度中文网2';
}
protected function before3()
{
$this->siteName = '网易3';
}
public function demo1()
{
return $this->siteName;
}
public function demo2()
{
return $this->siteName;
}
public function demo3()
{
return 'ss3';
}
你在是要从哪里获取方法的