multiple catch php code example
Example 1: multi catch for try php
<?php
try {
/* ... */
} catch (FirstException $ex) {
$this->manageException($ex);
} catch (SecondException $ex) {
$this->manageException($ex);
}
?>
<------------------------- To --------------------->
<?php
try {
} catch (FirstException | SecondException $ex) {
$this->manageException($ex);
}
?>
Example 2: php multiple catch exceptions
try
{
// Some code...
}
catch(AError | BError $e)
{
// Handle exceptions
}
catch(Exception $e)
{
// Handle the general case
}