try{}catch{}

try{
Db::name('user')->find();
}catch(\Exception $e){
$this->error($e->getMessage());
}$
this->success('执行成功!'); 

  


可以使用PHP的异常捕获进行必要的处理, 但需要注意一点, 在异常捕获中不要使用 think\Controller
异常处理
- 427 -
的error、 success和redirect方法, 因为上述三个方法会抛出 HttpResponseException 异常, 从而影响正
常的异常捕获, 例如:


猜你喜欢

转载自www.cnblogs.com/dayin1/p/11888572.html