Get the App
SLTechnology News&Howtos  ›  Development  › 

How to capture php error messages

Shulou Source: shulou.com Published: 2022-06-03 06:20:17 11月16日 Update

This article will explain in detail how to capture php error messages. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

PS:

1. Catch PHP syntax errors

two。 serious error

These two types of errors cannot be caught with normal set_error_handle, which is a technique for catching such errors.

The copy code is as follows:

/ / test.php page

Error_reporting (0)

Register_shutdown_function ('PageOnShutdown')

Include ('error_test.php')

Function PageOnShutdown ()

{

$msg = error_get_last ()

Print_r ($msg)

}

/ / error_test.php page

$a = 1 + 2

$b

Then output test.php and print out

Array ([type] = > 4 [message] = > parse error [file] = > D:\ web\ tbc\ error_test.php [line] = > 5)

Then you can write to the log according to getting $msg.

This is the end of this article on "how to capture php error messages". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Errors articles information code more pages good practical content skills articles logs knowledge grammar this is reference help related output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno Shulou Technology Shulou Information Huawei