Slide 52
Slide 52 text
Throwing Exceptions
function addTwoNumbers($a, $b) {
if(($a == 0) || ($b == 0)) {
throw new Exception("Zero is Boring!");
}
return $a + $b;
}
echo addTwoNumbers(3,2); // 5
echo addTwoNumbers(5,0); // error!!
Fatal error: Uncaught exception 'Exception'
with message 'Zero is Boring!'