[nycphp-talk] PhP error handler help -- totally confounded
Allen Shaw
ashaw at polymerdb.org
Mon Feb 4 16:18:29 EST 2008
Cliff Hirsch wrote:
> The error handler on my production server has stopped working. I ran some
> code to test it and am completely stuck. The trigger error line below works
> just fine. But php isn¹t directing it¹s errors to the error handler.
> blasasdfsdfgorg{; just stops dead. foobar(); which should also throw an
> error since it doesn¹t exist, also doesn¹t get caught by the error handler.
>
Hi Cliff,
The two types of errors your having trouble with are the type that can't
be handled easily with custom error handlers.
blasasdfsdfgorg(;
This makes a parse error. PHP won't get far enough to use your custom
handler because it will just die. Manual
<http://www.php.net/manual/en/function.set-error-handler.php> says:
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.
foobar(); (the function that doesn't exist):
I never tried this myself, but this comment
<http://www.php.net/manual/en/function.set-error-handler.php#73239>
suggests that normal custom error handlers won't be able to catch this.
You might be expecting an error message on screen, however, or at least
something besides a white page. If you're not getting it, it probably
means that display_errors
<http://www.php.net/manual/en/ref.errorfunc.php#ini.display-errors> is
turned off.
> Things were working until a few weeks ago and I can¹t think of any major
> changes since then.
Is it possible you weren't testing for parse errors and "call to
undefined function" errors back then?
- Allen
--
Allen Shaw
slidePresenter (http://slides.sourceforge.net)
More information about the talk
mailing list