Solved

Error Handling in PHP - set_error_handler("customError") $error_types

Posted on 2009-03-30
2
376 Views
Last Modified: 2013-12-13
How to use $error_types custom errors? Right now I am getting all the warnings/errors, I just want to see ONLY errors. How do I restrict my errors/warnings to ONLY E_ERROR? I want to avoid all rest of the warnings etc...

I have attached the code.
Thanks.



function customError($errno, $errstr, $errfile, $errline){ 
	//My code to send an email when error occurs
 }
//set error handler
set_error_handler("customError");

Open in new window

0
Comment
Question by:martyje
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Harte earned 500 total points
ID: 24020126
This should do it.
//set error handler
error_reporting (E_ERROR);
ini_set ('display_errors', '1');
 
function customError($errno, $errstr, $errfile, $errline)
{ 
        //My code to send an email when error occurs
}

Open in new window

0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question