Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-03-30
2
Medium Priority
?
415 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

916 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