set_error_handler

string set_error_handler(string handler_name) 

Uses a custom error handler to catch errors.

Returns:

Name of the previous error handler; NULL if the previous error handler was PHP’s built-in handler

Description:

set_error_handler() allows a user-defined function to be used as a custom error handler for errors triggered with trigger_error() and errors of the E_NOTICE, E_WARNING, and E_ERROR level.

Custom error handlers provide a simple way to separate your error-handling code from the code that triggers the error.

The user-defined function that handles the triggered errors can be as simple or elaborate as desired.

The function is passed two arguments. The first required argument is the level of the triggered error (USER_WARNING ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.