Bug #18437 Updated: Return value from custom error handler passed back to calling script

From: Date: Fri, 19 Jul 2002 16:33:59 +0000
Subject: Bug #18437 Updated: Return value from custom error handler passed back to calling script
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14644@lists.php.net to get a copy of this message
ID: 18437 Updated by: sniper@php.net Reported By: duncan@emarketeers.com -Status: Open +Status: Feedback Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 4.2.1 New Comment: This is the output with PHP 4.3.0-dev: "This fails: some text <br>But this works: some text <br>" (I don't understand your example..you never trigger those error levels..) Previous Comments: ------------------------------------------------------------------------ [2002-07-19 11:50:12] duncan@emarketeers.com If you set an error handler which returns rather than dying, then the return value of the handler is passed back to the script in place of the expected value iff the statement which raised the error is followed by a function call. Additionally, execution of the remainder of the statement is aborted. This means that e.g. if you reference an unset variable as part of an expression which contains function calls, the expression will evaluate to the return value of the error handler, which is NOT the behaviour if you have not got an error handler installed. i.e. the following will print This fails: --ERROR-- <br> But this works: some text <br> <? function myErrorHandler ($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_USER_ERROR: { echo "A fatal error occurred"; exit; } default : { } } return "--ERROR--"; } define (FATAL,E_USER_ERROR); define (ERROR,E_USER_WARNING); define (WARNING,E_USER_NOTICE); // set the error reporting level for this script error_reporting (FATAL | ERROR | WARNING); set_error_handler("myErrorHandler"); $c = "some text"; $a = $b . trim($c); echo "This fails: $a <br>"; $a = $b . $c; echo "But this works: $a <br>\n"; ?> My config line was: ./configure --with-xslt-sablot --enable-xslt --with-mysql --enable-mailparse --enable-mbstring ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18437&edit=1

« previous php.bugs (#14644) next »