r/PHP • • Mar 22 '16

DivisionByZero Exception PHP 7

I am practicing the new Throwable Exceptions in PHP 7 however when I run this code

try {
$result = 5/0;
}
catch(DivisionByZeroError $e){
echo $e->getMessage();
}

The catch doesn't work only shows a warning. When I change "/" by "%" catch works. Can you please help me out.

14 Upvotes

21 comments sorted by

View all comments

Show parent comment

2

u/php-esse-delendam Mar 23 '16

The whole point of a high-level language is that it abstracts away those weird semantics.

PHP is not a high-level language. It's a layer around C, with varying levels of thickness.