国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP 7 ?? ??

PHP 7??? ???? ??? ???? ??? ???????. PHP 5? ?? ?? ?? ????? ?? ???? ??? ?? Error ??? ?????.

?? ??? ?? ??? ?? ???? try/catch ???? catch? ? ????. ???? try / catch ??? ??? ??? ?? ?? ?? ??(set_Exception_handler()? ?? ???)? ?????. ?? ???? ???? ?? ?? ?? ???? ?????. ?, ???? ??? ?????.

Error ???? Exception ????? ???? ???? catch (Exception $e) { ... }? ?? ??? Error? ??? ? ????. catch (Error $e) { ... }? ?? ??? ????? ?? ???(set_Exception_handler())? ???? ??? ?? ? ????.

?? ?? ?? ??

  • Error
    • ArithmeticError
    • AssertionError
    • DivisionByZero ??
    • ParseError
    • TypeError
  • Exception
    • ...

1458887252-2773-exception-hiearchy.jpg

Instance

<?php 
class MathOperations  
{ 
   protected $n = 10; 

   // 求余數(shù)運算,除數(shù)為 0,拋出異常 
   public function doOperation(): string 
   { 
      try { 
         $value = $this->n % 0; 
         return $value; 
      } catch (DivisionByZeroError $e) { 
         return $e->getMessage(); 
      } 
   } 
} 

$mathOperationsObj = new MathOperations(); 
print($mathOperationsObj->doOperation()); 
?>

? ???? ??? ?? ??? ??? ????.

Modulo by zero
???? ??
||
<?php class MathOperations { protected $n = 10; // 求余數(shù)運算,除數(shù)為 0,拋出異常 public function doOperation(): string { try { $value = $this->n % 0; return $value; } catch (DivisionByZeroError $e) { return $e->getMessage(); } } } $mathOperationsObj = new MathOperations(); print($mathOperationsObj->doOperation()); ?>