开发者

How to hide the divide by zero exception in php?

开发者 https://www.devze.com 2023-02-23 18:32 出处:网络
i tried this error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); but its not working and printing the error like this...

i tried this error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

but its not working and printing the error like this...

Warning: Division by zero in C:\wamp\www\adman\webpage1\e开发者_开发问答learning.php on line 276


This is the best way to handle it:

if ( $divisor == 0 )
{
     // don't divide by zero, handle special case
} else {
     $result = $number / $divisor;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消