Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

why do we use php exceptions

<?php
  
  #We use exceptions to handle errors in PHP
  
  function divide($dividend, $divisor) {
  	if($divisor == 0) {
    	throw new Exception("Division by zero");
  	}
  return $dividend / $divisor;
}

echo divide(5, 0);
  
?>
 
PREVIOUS NEXT
Tagged: #php #exceptions
ADD COMMENT
Topic
Name
5+6 =