php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34507 Divide by zero error messages during parsing
Submitted: 2005-09-15 05:28 UTC Modified: 2005-09-15 09:28 UTC
From: levi at alliancesoftware dot com dot au Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.5 OS:
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: levi at alliancesoftware dot com dot au
New email:
PHP Version: OS:

 

 [2005-09-15 05:28 UTC] levi at alliancesoftware dot com dot au
Description:
------------
 If you have a divide by zero constant, the initial syntax check parsing catches it as an error even if the code is never executed.
 A consequence of this is that error_reporting() and set_ini('display_errors'..) are ignored since the error is triggeed before the php code is exectued.

 This in itself is not neccessarily a bug since you shouldn't have a constant divide by zero, but the error report doesn't tell you the file it came from (says unknown at line 0): this can be very frustrating if you have a large number of include() files).
  Setting display_error=0 in the .ini file is also ignored if error_reporting is on


Reproduce code:
---------------
#!/usr/local/bin/php
<?
if (0) $x = 5 / 0;
?>

Expected result:
----------------
File runs

or, if (error_reporting | E_WARNING) && display_errors

PHP Warning:  Division by zero in test.php on line 3

Actual result:
--------------
if (error_reporting | E_WARNING) and display_errors==0
  [stderr:]
PHP Warning:  Division by zero in Unknown on line 0

if (error_reporting | E_WARNING) and display_errors==1
  [stderr:]
PHP Warning:  Division by zero in Unknown on line 0
  [stdout:]
<br />
<b>Warning</b>:  Division by zero in <b>Unknown</b> on line <b>0</b><br />
  [ yes, the error is reported twice ]


if (error_reporting == 0)
  [ No output ]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-15 09:28 UTC] sniper@php.net
Seems to be fixed in PHP 5.1-dev.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 00:01:31 2025 UTC