PHP check thrown exception type
问题 Of course in PHP you can catch all thrown exceptions with: try{ /* code with exceptions */ }catch(Exception $e) { /* Handling exceptions */ } But is there a way to check the exception type of the thrown exception from inside the catch block? 回答1: You can use get_class: try { throw new InvalidArgumentException("Non Sequitur!", 1); } catch (Exception $e) { echo get_class($e); } 回答2: You can have multiple catch blocks to catch different Exception types. See below: try { /* code with exceptions *