ID:               29550
 Updated by:       [EMAIL PROTECTED]
 Reported By:      colin at mms3 dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Output Control
 Operating System: Linux (2.4)
 PHP Version:      4.3.8
 New Comment:

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. 


Previous Comments:
------------------------------------------------------------------------

[2004-08-06 17:31:32] 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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29550&edit=1

Reply via email to