views:

15

answers:

1

Has PHP any ability to catch all types of exceptions in one catch block? Is there any way to do this:

try  
{  
throw new Exception; OR throw new MyException;  
}  
catch(???)  
{
// Catch both exception types  
}
+4  A: 

Exception is the super class of all exceptions. So:

catch (Exception $e) {
    // Catches any exception
}
Gumbo
While this is true, it's very often a horrible idea and if misused will lead to nasty bugs.
Daenyth
Wrikken