Home >Backend Development >PHP Problem >How to customize error function in php

How to customize error function in php

coldplay.xixi
coldplay.xixiOriginal
2020-08-14 16:04:182586browse

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

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn