php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25842 Error Reporting not catching parse errors
Submitted: 2003-10-11 23:08 UTC Modified: 2003-10-12 19:57 UTC
From: corrupted_wise at yahoo dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.4RC1 OS: Win XP SP1
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: corrupted_wise at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-10-11 23:08 UTC] corrupted_wise at yahoo dot com
Description:
------------
When attempting to catch an error with a set_error_handler function, it always misses a parse error.  For example, when loading a php file, no matter if require, include, require_once..etc. is used, the default php bold errors are displayed when the function is ignored.  Notice errors load fine, tho.

I have not made any changes to php.ini-dist, and no modules.
I'm running this on Apache 2.0.47.

Reproduce code:
---------------
<?php
function error_handler($errno, $errstr, $errfile, $errline, $errctx) {
    echo "\nerror_handler:\n\terrno=$errno\n\terrstr=$errstr\n";
    echo "\terrfile=$errfile\n\terrline=$errline\n";
    die();
}
set_error_handler("error_handler");
error_reporting(E_ALL);

// load file with parse error
include "error.php";
exit;
?>

Expected result:
----------------
error_handler:
 errno=4
 errstr=Parse error: parse error, unexpected ',', expecting ']' in error.php on line 65
 errfile=error.php
 errline=1

Actual result:
--------------
<b>Parse error: parse error, unexpected ',', expecting ']' in error.php on line 65</b>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-12 19:57 UTC] sniper@php.net
RTFM: http://www.php.net/set_error_handler

"Note:  The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and E_COMPILE_WARNING."

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC