Home>Article>Backend Development> How to output error message in php
How to output error prompts in php: 1. Open the corresponding PHP file; 2. Add "error_reporting(E_ALL);"; 3. Output the error message through the "function cache_shutdown_error() {...}" method That’s it.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php output an error message?
php output error message
error_reporting(E_ALL); function cache_shutdown_error() { $_error = error_get_last(); if ($_error && in_array($_error['type'], array(1, 4, 16, 64, 256, 4096, E_ALL))) { header("Content-Type: text/html; charset=utf-8"); echo '你的代码出错了:'; echo '致命错误:' . $_error['message'] . ''; echo '文件:' . $_error['file'] . ''; echo '在第' . $_error['line'] . '行'; } } register_shutdown_function("cache_shutdown_error");
It is best to put it at the front. If an error is reported and it terminates, this method cannot be executed.
Recommended study: "PHP video tutorial》
The above is the detailed content of How to output error message in php. For more information, please follow other related articles on the PHP Chinese website!