PHP异常捕获

摘要:php7和之前的异常操作不一样

1、在php7之前可以使用

try{
}catch (\Exception  $e){
    echo $e->getMessage();
}

2、PHP7可以使用Throwable

Throwable is the base interface for any object that can be thrown via a throw statement in PHP 7, including Error and Exception.

try{
}catch (\Throwable $e){
    echo $e->getMessage();
}


评论