下面由thinkphp教程栏目给大家介绍thinkphp中使用aop切面编程快速验证我们的数据,希望对需要的朋友有所帮助!
thinkphp中使用AOP切面编程快速验证我们的数据
<?php Namespace appcommonvalidate; use appcommoncontrollerBase; use thinkRequest; use thinkValidate; class BaseValidate extends Validate { /** * 基础类控制器 * @param null|array $data * @return bool */ public function goCheck($data = null) { # 当 data 不存在的时候去自动校验获取到的参数 if( is_null($data) ) { # 获取待验证的参数 $data = Request::instance()->param(); } # 进行验证 if( !$this->check($data) ) { (new Base())->ajaxjson(Base::error, $this->getError()); # 抛出的自定义异常 } return true; }
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END