Yii中特殊行为ActionFilter的使用方法示例
(编辑:jimmy 日期: 2025/12/28 浏览:3 次 )
新建 app\filters\LoggingFilter 继承 yii\base\ActionFilter
LoggingFilter 的功能: 在指定请求的 action 前后各记录一条日志
<"htmlcode"><"external nofollow" href="http://yii.test/index.php">http://yii.test/index.php"htmlcode">This is a logging for test\beforeAction. This is a testing for system/test. This is a logging for test\afterAction.请求 http://yii.test/index.php"htmlcode">
This is a testing for system/test-one.请求 http://yii.test/index.php"htmlcode">
This is a testing for system/test-two.总结
Yii 中的 ActionFilter(过滤器)相当于 Laravel 中的 Middleware(中间件),beforeAction 相当于前置中间件,afterAction 相当于后置中间件。
下一篇:PHP 99乘法表的几种实现代码
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。