基本上他们会说如果你没有设置一个catch语句来捕获customException它将会落入一般的Exceptioncatch语句.
在此示例中,第一个catch语句将捕获,customException因为它明确地设计为这样做.
try {
// fail
throw new customException();
}
catch (customException $e) {
// catch custom exception
}
catch (Exception $e) {
// catch any uncaught exceptions
}
Run Code Online (Sandbox Code Playgroud)
在下一个示例中,因为它缺少通用Exceptioncatch块的子句将捕获它:
try {
// fail
throw new customException();
}
catch (Exception $e) {
// catch any uncaught exceptions
}
Run Code Online (Sandbox Code Playgroud)