470,855 Members | 1,200 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

Why my error handler function can not work?

Hi, all
I want to write my own error handler function in php by using
"set_error_handler()" function. I have made a test for this function but
found it did not work. My test code is as following:
<?php
function myerrorHandler ($errno, $errstr, $errfile, $errline,
$errcontext)
{
switch ($errno)
{
case E_USER_WARNING:
case E_USER_NOTICE:
case E_WARNING:
case E_NOTICE:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_ERROR:
case E_ERROR:
case E_PARSE:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
echo "This is my own error handler
function\n";
die();
}
}
set_error_handler("myerrorHandler");
Undefined();
?>

In the code, "Undefined()" is a function which is not defined in the
file, so it should produce a error message.
If my own handler function works, it should print "This is my own error
handler function". but actually, when my program runs, it gives the
error report:
"Fatal error: Call to undefined function: undefined() in
/var/www/localhost/htdocs/hello.php on line 28"
which means handler function doesn't work.
What is wrong? why the function "set_error handler" can not work?
Thanks for your suggestion!
Jul 17 '05 #1
2 2367
Lian Liming a écrit:
Hi, all
I want to write my own error handler function in php by using
"set_error_handler()" function. I have made a test for this function but
found it did not work. My test code is as following: ..... What is wrong? why the function "set_error handler" can not work?
Thanks for your suggestion!


Read carefully the appropiate doc and ex :
http://www.php.net/manual/en/functio...or-handler.php

Jul 17 '05 #2
The following types of error cannot be managed with this function: E_ERROR,
E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and
E_COMPILE_WARNING.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Wayno | last post: by
1 post views Thread by Timh Bergström | last post: by
6 posts views Thread by Peter Frost | last post: by
2 posts views Thread by Steve Richfield | last post: by
13 posts views Thread by Thelma Lubkin | last post: by
10 posts views Thread by Paul Gorodyansky | last post: by
5 posts views Thread by kellygreer1 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.