Thinkphp5-前置操作
<?php
namespace appindexcontroller;
use thinkController;
class Index extends Controller
{
protected $beforeActionList = [
"first", //在执行所有方法前都会执行first方法
"second" => ["except"=>"hello"], //除hello方法外的方法执行前都要先执行second方法
"three" => ["only"=>"hello,data"], //在hello/data方法执行前先执行three方法
];
protected function first()
{
echo "first<br/>";
}
protected function second()
{
echo "second<br/>";
}
protected function three()
{
echo "three<br/>";
}
public function hello()
{
return "hello";
}
public function data()
{
return "data";
}
}
如注释所言,为TP5的前置操作。
在以下URL中访问:
http://127.0.0.1/demo/public/index.php/index/index/hello
有如下显示:
first
three
hello
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: ThinkPHP5-简单的批量查询
- 下一篇:没有了
