set_error_handler() UNDEFINED?
| From: | TR Henigson | Date: | Wed, 25 Oct 2000 21:44:08 +0000 |
| Subject: | set_error_handler() UNDEFINED? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-21944@lists.php.net to get a copy of this message | ||
I don't understand how to use the set_error_handler() funciton. I'm
testing it with the script listed below from Zend.com. Here's the link:
http://www.zend.com/zend/art/mistake1.php#Heading10
If I set error_reporting(15) (or anything greater than 0, in fact), I get
the following error:
error Fatal error: Call to undefined function: set_error_handler() in ...
If I lower the error_reporting(0), I don't get the fatal error, but I
get an empty HTML document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=iso-8859-1"></HEAD>
<BODY></BODY></HTML>
In no case does the file error_file, with permissions 777, ever get written
to. Can you shed any light on my confusions? Thank you,
Ted
<?php
// void error_handler(string type, string message, string file, int line)
// Custom error handler, set by the set_error_handler()
// function.
//
function error_handler ($type,
$message,
$file=__FILE__,
$line=__LINE__)
{
error_log("$message, $file, $line", 3, 'error_file');
if ($type & E_ERROR) {
print 'An error occurred, it has been logged
and it will be addressed.';
exit;
}
}
set_error_handler('error_handler');
?>