By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,695 Members | 1,170 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,695 IT Pros & Developers. It's quick & easy.

Why my error handler function can not work?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.