Home > Backend Development > PHP Problem > How to display php errors on the page

How to display php errors on the page

藏色散人
Release: 2023-03-02 06:54:01
Original
3526 people have browsed it

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 display php errors on the page

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:

How to display php errors on the page

# 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(); ?>
Copy after login

Open it on the browser, then press Ctrl f to search for display_errors, the display is as follows:

How to display php errors on the page

Search php.ini again and find the path to the php configuration file, as shown below:

How to display php errors on the page

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
Copy after login

Refresh the phpinfo.php script on the browser, find display_errors,

How to display php errors on the page

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
Copy after login

How to display php errors on the page

Refresh the page again, the result is displayed as follows,

How to display php errors on the page

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!

Related labels:
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