How to display php errors on the page: first execute the script "phpinfo.php"; then find the path to the php configuration file; then edit the "php.ini" file and modify the content to "display_errors = On"; Finally, restart "php-fpm".
How to solve the problem that php error messages are not displayed on the browser
[System environment] deepin15.8
[Programming environment] nginx1.13 php7 atom1.22
I am learning PHP these days, and I found that various error messages in PHP are not displayed on the browser, even if there are Even if there is a slight syntax error, the execution result will be as shown below:
# Therefore, I have to find detailed error information in the log file, but if I check it every time an error occurs Logs are so annoying.
The following is the solution.
Execute the following script phpinfo.php:
<?php phpinfo(); ?>
Open it on the browser, then press Ctrl f to search for display_errors, the display is as follows:
Search php.ini again and find the path to the php configuration file, as shown below:
Edit the php.ini file, and then restart the service:
sudo vi /etc/php/7.2/fpm/php.ini # 找到display_errors并修改为 display_errors = On # 重启php-fpm sudo systemctl restart php7.2-fpm
Refresh the phpinfo.php script on the browser, find display_errors,
The error message will not be displayed when executing other php scripts containing syntax errors, but will be the same as before.
I didn’t know how to solve it at this point, so I went to search online. It said that I had to configure it in the php-fpm pool and set php_flag[display_errors] to on
sudo vi /etc/php/7.2/fpm/pool.d/www.conf # 找到php_flag[display_errors]并设置为on
Refresh the page again, the result is displayed as follows,
Execute a php script with syntax errors, display the error message, and you're done!
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to display php errors on the page. For more information, please follow other related articles on the PHP Chinese website!