Answers for "multi catch for try php"

PHP
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);
}
?>
Posted by: Guest on August-19-2020
-2

php multiple catch exceptions

try
{
    // Some code...
}
catch(AError | BError $e)
{
    // Handle exceptions
}
catch(Exception $e)
{
    // Handle the general case
}
Posted by: Guest on April-22-2020

Browse Popular Code Answers by Language