php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24216 set_error_handler without effect in some situations
Submitted: 2003-06-17 01:24 UTC Modified: 2003-06-17 02:14 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: redeye at erisx dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.2 OS: Linux / Windows
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: redeye at erisx dot de
New email:
PHP Version: OS:

 

 [2003-06-17 01:24 UTC] redeye at erisx dot de
Description:
------------
It seams like PHP doesn't keep the error_handler when a function is called which contains another trigger_error. This can lead to a quite unwanted behaviour on scripts that require an own error_handler.

Reproduce code:
---------------
<?php

function my_error_handler($error_number,$error_message,$error_filename,$error_line){
    echo 'Using my_error_handler: '.$error_message.'<br>';

    if ( $error_number == E_USER_NOTICE ){
        call_error();
    }
}
function call_error(){
    trigger_error('From call_error()', E_USER_WARNING);
}

set_error_handler('my_error_handler');

trigger_error('test', E_USER_NOTICE);
trigger_error('another test', E_USER_NOTICE);

?>

Expected result:
----------------
Using my_error_handler: test
Using my_error_handler: From call_error()
Using my_error_handler: another test
Using my_error_handler: From call_error()

Actual result:
--------------
Using my_error_handler: test
Warning: From call_error() in /www/test.php on line 11
Using my_error_handler: another test
Warning: From call_error() in /www/test.php on line 11


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-17 02:14 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected behavior, otherwise PHP will end up in a never-ending loop calling the error handler from the error handler...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 28 14:00:03 2025 UTC