Home>Article>Backend Development> How to customize error function in php
How to customize the error function in php: 1. Write an error handling function with fixed parameters, which is [$errno, $errstr]; 2. Set the error handling method [set_error_handler()].
How to customize error function in php:
1) Write an error handling function and name the function yourself , but the parameters are fixed, $errno, $errstr, where the former defaults to the error level, and the latter is the specific information of the error.
2) Set the error handling method. set_error_handler("The error handling function you named yourself."); In this way, all errors will be handled in the way you set. In addition, if you only control a certain type of error handling:
3) Set the error handling method. set_error_handler("The error handling function you named yourself.", some fixed constants); In this, the fixed constants are set by PHP and represent different error registrations, including:E_WARNING, E_NOTICE
Wait
Relevant learning recommendations:php programming(video)
The above is the detailed content of How to customize error function in php. For more information, please follow other related articles on the PHP Chinese website!