php error_reporting(E_ALL) 不会产生错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16933606/
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 11:54:43  来源:igfitidea点击:

error_reporting(E_ALL) does not produce error

php

提问by Samik Sengupta

This is my php script-

这是我的 php 脚本-

<?php
  error_reporting(E_ALL);
  echo('catch this -> ' ;. $thisdoesnotexist);
?>

Which obviously should show something if it were to be executed.

如果要执行它,这显然应该显示一些东西。

All I see is an empty page. Why is error_reporting(E_ALL)not working?

我看到的只是一个空白页。为什么error_reporting(E_ALL)不工作?

<?php
  ini_set("display_errors", "1");
  error_reporting(E_ALL);
  echo('catch this -> ' ;. $thisdoesnotexist);
?>

Does not help either. All I get is an empty page.

也没有帮助。我得到的只是一个空白页。

I've been to php.iniand set display_errors = Onand display_startup_errors = On. Nothing happens.

我去过php.ini和设置display_errors = Ondisplay_startup_errors = On。没发生什么事。

回答by sectus

Your file has syntax error, so your file was not interpreted, so settings was not changed and you have blank page.

你的文件有语法错误,所以你的文件没有被解释,所以设置没有改变,你有空白页。

You can separate your file to two.

您可以将文件一分为二。

index.php

索引.php

<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
include 'error.php';

error.php

错误.php

<?
echo('catch this -> ' ;. $thisdoesnotexist);

回答by deceze

That error is a parse error. The parseris throwing it while going through the code, trying to understand it. No code is being executed yet in the parsing stage.Because of that it hasn't yet executed the error_reportingline, therefore the error reporting settings aren't changed yet.

该错误是解析错误。该解析器是把它扔经历的代码,同时,试图了解它。在解析阶段还没有执行任何代码。由于它尚未执行该error_reporting行,因此错误报告设置尚未更改。

You cannot change error reporting settings (or really, do anything) in a file with syntax errors.

您不能在有语法错误的文件中更改错误报告设置(或实际上,做任何事情)。

回答by som

In your php.ini file check for display_errors. I think it is off.

在你的 php.ini 文件中检查display_errors. 我认为它关闭了。

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

回答by Altaf Hussain

In your php.ini file check for display_errors. If it is off, then make it on as below:

在您的 php.ini 文件中检查 display_errors。如果关闭,则按如下方式打开:

display_errors = On

It should display warnings/notices/errors .

它应该显示 warnings/notices/errors 。

Please read this

请阅读这个

http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

回答by Kaushal Roy

you can try to put this in your php.ini:

你可以尝试把它放在你的 php.ini 中:

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

In php.ini file also you can set error_reporting();

在 php.ini 文件中也可以设置 error_reporting();