PHP 不显示错误信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5680831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:11:23  来源:igfitidea点击:

PHP does not display error messages

phperror-handling

提问by user700792

I installed XAMPP 1.7.4 (with PHP 5.3.5), the problem is PHP does not display any error messages. E.g. if I connect to MYSQL with mysql_connect()without parameters, PHP will not complain about the required fields.

我安装了 XAMPP 1.7.4(使用 PHP 5.3.5),问题是 PHP 不显示任何错误消息。例如,如果我mysql_connect()不带参数连接到 MYSQL ,PHP 将不会抱怨必填字段。

Why is this?

为什么是这样?

How can I configure PHP to display errors?

如何配置 PHP 以显示错误?

回答by Jeff Lambert

To turn on errors at the script level, include at the top of your script:

要在脚本级别打开错误,请在脚本顶部包含:

ini_set('display_errors', 1);
error_reporting(~0);

Alternatively, if it is nota production site and simply a development / testing site, you can turn on error reporting in php.ini. Search it for these settings:

或者,如果它不是生产站点而只是一个开发/测试站点,您可以在 php.ini 中打开错误报告。搜索这些设置:

error_reporting  =  E_ALL
;error_reporting  =  E_ERROR
display_errors = On
;display_errors = Off

回答by Shakti Singh

May be the display error is off

可能是显示错误关闭

add in .htaccess file of your application.

添加应用程序的 .htaccess 文件。

php_value display_errors on

OR

或者

use this at the top of your php script

在 php 脚本的顶部使用它

ini_set('display_errors',"1");

回答by Sunny S.M

To show error message on page over browser for php script use following code in top of your php file.

要在 php 脚本的浏览器页面上显示错误消息,请在 php 文件顶部使用以下代码。

<?php 
ini_set('display_errors', 1);
error_reporting(~0);
?>

and there is another way to check php error code if you are linux ubuntu user execute following command on terminal.

如果您是 linux ubuntu 用户,还有另一种方法可以检查 php 错误代码在终端上执行以下命令。

NOTE : -10 is the number of message you want to show.

注意:-10 是您要显示的消息数。

enter image description here

在此处输入图片说明

回答by Bjoern

It possibly did override your settings in the php.ini. Check the php.ini for error handling parameters and make sure they're switched on.

它可能确实覆盖了您在 php.ini 中的设置。检查 php.ini 中的错误处理参数并确保它们已打开。

Happened to me a few weeks ago, too

几周前也发生在我身上

回答by Ram Choubey

You can use following code in your program

您可以在程序中使用以下代码

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