|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51757 Division By Zero triggers Warning instead of Fatal Error
Submitted: 2010-05-06 16:14 UTC Modified: 2010-05-10 12:20 UTC
From: Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2010-05-06 16:14 UTC]
In PHP 5.3 (and probably 5.2x as well) a division by Zero returns null and 
squelches a warning.  The issue becomes when the return is cast to Int as is done 
via soap service which is where I discovered this issue.

Test script:
$val = 5/0;
echo (int)$val;

Expected result:
Fatal Error: Division by zero in /var/www/reproduction/test.php on line 3

Actual result:
Warning: Division by zero in /var/www/reproduction/test.php on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-06 16:23 UTC]
-Summary: Division By Zero in Soap Service Returns 0 +Summary: Division By Zero triggers Warning instead of Fatal Error
 [2010-05-06 16:23 UTC]
Changed title to reflect scope of the bug.
 [2010-05-10 12:20 UTC]
-Status: Open +Status: Bogus
 [2010-05-10 12:20 UTC]
Division by zero generating a warning rather than an error has been PHP's behaviour since at least April 1999, per a couple of minutes with svn blame/log. I don't see much chance that we'd want to break backward compatibility on that now.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 09:01:29 2024 UTC