php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29550 error handler not used by create_function parser
Submitted: 2004-08-06 17:31 UTC Modified: 2004-08-17 00:23 UTC
From: colin at mms3 dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.8 OS: Linux (2.4)
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: colin at mms3 dot com
New email:
PHP Version: OS:

 

 [2004-08-06 17:31 UTC] colin at mms3 dot com
Description:
------------
I am writing an application which allows the 'user' to specify some PHP code. This is then invoked at run-time by the create_function() function.

I want to provide a facility for pre-checking this code by using a custom error-handler, however the errors seem to be getting handled by the built-in error handler.

Reproduce code:
---------------
function lister_check_errors($errno, $errstr, $errfile, $errline)
{
    global $lister_embed_errors;
    $lister_embed_errors.="$errno: $errstr<br />\n&nbsp; in line $errline";
}
function lister_check_syntax($code,$params)
{
    global $lister_embed_errors;
    $lister_embed_errors='';
    $errhandler=set_error_handler('lister_check_errors');
    $fn=create_function($params,$code);
    restore_error_handler();
    return($lister_embed_errors);
}

$stored=lister_check_syntax("{{{{ bad stuff", '$something');
print strlen($stored);

Expected result:
----------------
I expected to just get an integer back, but it behaves as if I hadn't called set_error_handler()

Actual result:
--------------
The following was output to the browser:

Parse error: parse error, unexpected T_STRING in /home/colin/public_html/form/check_err.php(15) : runtime-created function on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-17 00:23 UTC] iliaa@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

Parse errors are fatal errors that cannot be captured via 
PHP's error handling mechanism. 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 09:01:33 2025 UTC