php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39027 Modulus by 0 gives no warning, while division does
Submitted: 2006-10-03 17:06 UTC Modified: 2006-10-03 17:54 UTC
From: ludicruz at yahoo dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.1.6 OS: linux 26.17
Private report: No CVE-ID: None
 [2006-10-03 17:06 UTC] ludicruz at yahoo dot com
Description:
------------
taking a modulus with 0 does not give a warning or an error rather it returns a boolean false. dividing by 0 gives a warning. I think for consistancies sake (since it is practically the same operation depending on architecture) both should either give a warning or both should return boolean false;

Reproduce code:
---------------
<?php
var_dump(1/0);
var_dump(1%0);
?>

Expected result:
----------------
Warning: Division by zero in /srv/www/hosts/seniorcaringcall.ithinc.net/public_html/tmp.php on line 2
bool(false) 
Warning: Division by zero in /srv/www/hosts/seniorcaringcall.ithinc.net/public_html/tmp.php on line 3
bool(false)

//OR
bool(false)
bool(false)

Actual result:
--------------
Warning: Division by zero in /srv/www/hosts/seniorcaringcall.ithinc.net/public_html/tmp.php on line 2
bool(false) bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-03 17:54 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC