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
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: Qt编程17:QFont文字属性设置(简单使用)
- 下一篇: Delphi中如何进行BASE64解码