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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 02:01:38 2025 UTC