How to automatically get errors and exceptions in PHP?

WBOY
Release: 2016-08-08 09:06:50
Original
780 people have browsed it

In an online production environment, programs will inevitably encounter errors and exceptions.
We will not find most of these errors and exceptions, so how to automatically obtain these errors and exceptions?
That is, as long as the program encounters errors and exceptions, it will write these errors and exceptions to the Log for recording?
Thank you!

Reply content:

In an online production environment, programs will inevitably encounter errors and exceptions.
We will not find most of these errors and exceptions, so how to automatically obtain these errors and exceptions?
That is, as long as the program encounters errors and exceptions, it will write these errors and exceptions to the Log for recording?
Thank you!

This requires configuring PHP

  • log_errors=On

  • error_log=Log path
    PHP will automatically write to the log when an error occurs.

Define functions, related as follows

  • set_error_handler: Set user-defined error handling function

  • set_exception_handler: Set user-defined exception handling function

The two functions set_exception_handler and set_error_handler can handle uncaught exceptions, then analyze and classify the exception information and write it to the log

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!