手动报异常(不能处理语法错误)
try {
throw new Exception("错误提示信息");
} catch (\Exception $e) {
$msg = empty($e->getMessage()) ? '服务器异常' : $e->getMessage();
$data = ['code' => -1, 'msg' => $msg];
} finally {
}
捕获语法错误(php>=7.0)
try {
调用不存在的函数();
} catch (Throwable $e) {
echo '捕获到异常和错误';
}