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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 09:01:30 2024 UTC