RE: [PHP] class and error handling
| From: | Martin Towell | Date: | Thu, 16 May 2002 05:57:57 +0000 |
| Subject: | RE: [PHP] class and error handling | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-97874@lists.php.net to get a copy of this message | ||
Have a look at this page
http://www.php.net/manual/en/function.set-error-handler.php
and at the user comments dated: "09-Sep-2001 03:16" and "01-Mar-2002 11:52"
these might help you
Martin
-----Original Message-----
From: Gerard Samuel [mailto:gsam@trini0.org]
Sent: Thursday, May 16, 2002 3:52 PM
To: PHP
Subject: [PHP] class and error handling
2 things that are foriegn to me. Im trying to construct a class to
handle errors.
I started out trying to make it recognise errors in the first place and
then expand, but Im having difficulty.
class.php
<?php
class eh
{
function eh()
{
error_reporting (E_ERROR | E_WARNING | E_PARSE);
set_error_handler($this->errorhandler);
}
function errorhandler($type, $str, $file, $line)
{
switch ($type)
{
case E_ERROR:
echo 'ERROR OCCURED';
break;
case E_WARNING:
echo 'YOUR WARNING!';
break;
}
}
}
?>
-----------------------------------------------------------
test.php
<?php
require_once('./class.php');
$eh = new eh();
join (':', $next);
?>
Whenever I run test.php, I get the regular php error page instead 'ERROR
OCCURED'. Im not sure if I can feed set_error_handler the way I did.
Does anyone see anything wrong with this piece of code?
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php