Jump to content

PHP Division By Zero?


ShoeLace1291

Recommended Posts

So, this is something that I've been wondering for a while now... say you have two variables that you need to divide to find a certain percentage and one happens to be zero... why does PHP feel the need to return a warning saying there was a division by zero?  why not just return the number zero since anything that's divided by zero always results in zero anyway?  Just a random thought.

Link to comment
https://forums.phpfreaks.com/topic/249894-php-division-by-zero/
Share on other sites

That not true, division by zero is NOT equal to zero.  Just basic math.  Example, you have 3 / 0 != 0 because  0 x 0 != 3.  You get the point.  In which case, in PHP you can use the Error Suppression Operator, something like this.

 

$a = @(25/0);

 

Using the '@' Operator, the error is suppressed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.