douyi9705 2016-05-24 16:35
浏览 127
已采纳

PHP:[错误]如果只有“error_reporting”可以隐藏或显示错误,为什么“display_errors”存在?

EDIT: My Environment is the following (this is relevant to the answer):

  • Microsoft IIS 10.0 Express
  • Windows 7 Professional SP1
  • PHP Version 5.6.16 x86 FastCGI

I am trying to figure out what purpose the setting "display_errors" has. In the following code, I am attempting to hide the PHP Notice that is thrown at line 9. Naturally one would think that simply setting

 display_errors = 'Off'

would accomplish this, but it seems to have no effect.

I am of the understanding that "error_reporting" lets you choose which errors are caught, and "display_errors" determines whether or not the error messages are echoed to the user. Am I mistaken? In most of my Google searches, I see people setting both

error_reporting = 0

and

display_errors = 'Off'

But, why even bother with

   display_errors = 'Off'

when it does not have an effect anyway?

My test code:

<?php
//ini_set("error_reporting", 0);
ini_set("display_errors", "Off");
ini_set("display_startup_errors", "Off");
date_default_timezone_set("America/Chicago");

echo "Hey<br />";

echo $myarr["hey"];

When I run this code, I see the following error message (this is a link to the image, since I don't have enough reputation to post it here):

http://i.imgur.com/mupV8BO.png

PHP: The error message generated for line 9 should be hidden from the user. Why does "display_errors" exist if it does nothing?

  • 写回答

2条回答 默认 最新

  • dongzu0742 2016-05-24 21:19
    关注

    After trial and error and using ShiraNai7's explanations I have found that this is a bug in PHP on Microsoft IIS and FastCGI. See link to bug:

    Bug #44729 display_errors = Off not respected

    https://bugs.php.net/bug.php?id=44729

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换