【问题标题】:PHP notices shown even display_errors is Off and error_reporting is 0即使 display_errors 为 Off 且 error_reporting 为 0 也会显示 PHP 通知
【发布时间】:2019-12-28 22:39:27
【问题描述】:

VmWare 云服务器

CentOS Linux 7.6.1810 - Php 5.6.40 - Apache/2.4.6

test.php

<?php
  echo($x);
  phpinfo();
?>

输出:

注意:/var/www/html/test.php 第 1 行中未定义的变量 x

在 phpinfo 输出的 CORE 部分我有

display_errors 关闭

display_startup_errors 关闭

error_reporting 0

为什么会显示通知?

我不想显示任何错误/通知/警告等。

【问题讨论】:

标签: php centos7 error-reporting


【解决方案1】:

您的设置可能在 htaccess 文件中控制,请参阅更多信息:https://www.php.net/manual/en/configuration.changes.php

但是你可以试试这个:

<?php
ini_set('display_errors', 0);
echo($x);
phpinfo();

【讨论】:

    【解决方案2】:

    尝试在 PHP 脚本的顶部添加以下内容:

    <?php error_reporting(0); ?>
    

    如果通知消失,我建议确保您正在修改好的 php.ini 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      • 2015-05-07
      • 2017-12-14
      • 1970-01-01
      • 2016-09-22
      相关资源
      最近更新 更多