Home >Backend Development >PHP Problem >How to output pop-up error message in php
How to output pop-up error prompts in php: 1. Open the corresponding PHP file; 2. Add "error_reporting(E_ALL);"; 3. Output through the "function cache_shutdown_error() {...}" method Just the error message.
The operating environment of this system: Windows 10 system, PHP version 7.1, DELL G3 computer.
php method of outputting error information
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 '<font color=red>你的代码出错了:</font></br>'; echo '致命错误:' . $_error['message'] . '</br>'; echo '文件:' . $_error['file'] . '</br>'; echo '在第' . $_error['line'] . '行</br>'; } } register_shutdown_function("cache_shutdown_error");
It is best to put it at the front. If the error is reported and terminated, this method cannot be executed.
In short, PHP output pop-up windows can be used to promptly prompt users with error messages, improve user experience, and enhance security. Hackers often exploit application vulnerabilities, so validation and error handling of input is crucial.
The above is the detailed content of How to output pop-up error message in php. For more information, please follow other related articles on the PHP Chinese website!