Re: class and error handling
| From: | Gerard Samuel | Date: | Thu, 16 May 2002 06:11:44 +0000 |
| Subject: | Re: class and error handling | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97875@lists.php.net to get a copy of this message | ||
I modified my example against user comment dated "01-Mar-2002 11:52" and I got the desired output.
Thanks
Martin Towell wrote:
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