Home >Backend Development >PHP Problem >What should I do if php does not display error messages?

What should I do if php does not display error messages?

藏色散人
藏色散人Original
2020-08-29 10:22:323273browse

Solution to php not displaying error messages: First find and open the "php.ini" file; then modify the content to "error_reporting = E_ALL" and "display_errors = On"; finally save the changes.

What should I do if php does not display error messages?

Recommended: "PHP Video Tutorial"

Solution to php not outputting error message

After installing lnmp, the browser page does not output errors, but the error message can be seen in the nginx error log. The reason is that php-fpm does not output error messages by default, because when we installed yum, we used it by default It is the php.ini configuration environment of the production environment. This must be blocked in the production environment, otherwise people will see all your mistakes and your code will be unsafe.

Solution:

vim /etc/php.ini

Just change the following two items!

error_reporting = E_ALL
display_errors = On

What should I do if php does not display error messages?

If you want to temporarily output the error on the page, just add the following code at the top of the page where you want to output the error!

error_reporting(-1);
ini_set('display_errors', 1);

See it, the cute error page is out again!

The above is the detailed content of What should I do if php does not display error messages?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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