|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-17 00:23 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 21:00:01 2025 UTC |
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 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