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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.