Page 1 of 1

Evil error reporting

Posted: Fri May 27, 2005 4:21 am
by Bitmaster
I'm developing a web service in PHP using nuSOAP and, for safety and security reasons, I would like to terminate the script in case ANY kind of notice, warning or error occurs. The desired behaviour would be to log the message and kill the script.

Code: Select all

<?php

ini_set ("display_errors", "0");

function test ($i)
{
	return ($i + 1);
}

test ($problem); //Notice: undefined variable

echo ("Script execution continues..."); //Unfortunately...

?>
In this sample script, the notice is NOT logged and the script just continues its execution, and that can cause all sorts of other problems...

Is there any way to log everything (including notices) and terminate the script ?

PS: I've already looked into set_error_handler, but:

" The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called."


Thanks in advance !

Posted: Fri May 27, 2005 12:10 pm
by JAM

Posted: Fri May 27, 2005 1:23 pm
by Syranide
you can't use set_error_handler as those errors cannot be interpreted by scripts... because of the fact that they occur prior to execution.

therefore there is not thing you can do about such errors in scripts, the only once you can deal with are those inflicted at runtime by your code, and these can be dealt with using set_error_handler (and really there is no need to handle the other ones as they CANNOT occur by themself once your script is working, in other words, should only appear during development).