php.net |  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: sstratton@php.net 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sstratton@php.net
New email:
PHP Version: OS:

 

 [2010-05-06 16:14 UTC] sstratton@php.net
Description:
------------
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:
---------------
<?PHP
$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
int(0)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-06 16:23 UTC] sstratton@php.net
-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] sstratton@php.net
Changed title to reflect scope of the bug.
 [2010-05-10 12:20 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-05-10 12:20 UTC] aharvey@php.net
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: Thu Mar 28 19:01:29 2024 UTC