在 xampp 中关闭 php 错误报告?

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

Turn php error reporting off in xampp?

php

提问by eveo

I just installed xampp, getting errors all over the place. Want to get rid of error handling. It's only annoying errors to do with my variables.

我刚刚安装了 xampp,到处都是错误。想摆脱错误处理。这只是与我的变量有关的烦人错误。

I'm not sure where to find php.ini, it doesn't exist in my C:\xampp\apache

我不确定在哪里可以找到 php.ini,它不存在于我的 C:\xampp\apache

回答by 72lions

Inside your php.ini make sure that you have display_errors to off. From what I understand if you set display_errors to Off then the error_reporting directive doesn't need to change.

在 php.ini 中,确保关闭 display_errors。据我了解,如果您将 display_errors 设置为 Off 则 error_reporting 指令不需要更改。

Example:

例子:

error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off

回答by Ralph

in php.ini, do the following change,

在 php.ini 中,进行以下更改,

display_errors = Off

回答by Mark

This is very old now, but in case someone comes across this there's a XAMMP issue with version 5.6.3. I had the same issue with error display set to 'off' and it was still showing up as on in phpinfo()

这现在已经很老了,但如果有人遇到这个问题,版本 5.6.3 存在 XAMMP 问题。我有同样的问题,错误显示设置为“关闭”,它仍然在 phpinfo() 中显示为打开

For some reason, they added the error reporting in php.ini twice. display_errorsshows on line 99 of php.ini, and then again on line 552.

出于某种原因,他们在 php.ini 中添加了两次错误报告。display_errors显示在 php.ini 的第 99 行,然后再次显示在第 552 行。

So if you scroll down and disable the first one, the second one is still set to 'on' and overrides the first one leaving error reporting active.

因此,如果您向下滚动并禁用第一个,第二个仍设置为“打开”并覆盖第一个,使错误报告处于活动状态。

I'm sure this will be fixed with future versions of XAMMP, but wanted to add this here for anyone that comes here looking for an answer to this problem.

我确信这将在 XAMMP 的未来版本中得到解决,但想在此处为任何来这里寻找此问题答案的人添加此内容。

回答by Claudio

Xampp and other web applications have an error interface to show programmers (and users) execution errors or warnings (notices). In order to modify the way Xampp shows errors you have to go control panel and open php.ini. Inside this file you can find two points to modify the way it shows errors:

Xampp 和其他 Web 应用程序有一个错误界面来向程序员(和用户)显示执行错误或警告(通知)。为了修改 Xampp 显示错误的方式,您必须转到控制面板并打开 php.ini。在此文件中,您可以找到两点来修改显示错误的方式:

  1. “display_errors = On”. From my point of view it has to be On all the time. If you put Off you won't have any info regarding bad sentences.

  2. “error_reporting=E_ALL”. This is the key point. Changing the value of it you can change the way it shows errors. Inside php.ini is documented all options. My favorites:

    • error_reporting=E_ALL ? it shows everything. Good for debug.
    • error_reporting=E_ALL & ~E_STRICT & ~E_DEPRECATED ? it shows errors & notice (very important for debugging) and not shows suggestions & deprecated functions in next php versions.
    • error_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ? production environment not including Notices.
  1. “display_errors = On”。从我的角度来看,它必须始终处于开启状态。如果您推迟关闭,您将不会有任何关于坏句子的信息。

  2. “error_reporting=E_ALL”。这是关键点。改变它的值,你可以改变它显示错误的方式。在 php.ini 中记录了所有选项。我最喜欢的:

    • error_reporting=E_ALL ? 它显示了一切。适合调试。
    • error_reporting=E_ALL & ~E_STRICT & ~E_DEPRECATED ? 它显示错误和通知(对于调试非常重要),而不显示下一个 php 版本中的建议和不推荐使用的功能。
    • error_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ? 生产环境不包括公告。

I hope this fit for you.

我希望这适合你。

More details https://community.apachefriends.org/f/viewtopic.php?f=17&t=50989

更多详情https://community.apachefriends.org/f/viewtopic.php?f=17&t=50989

回答by Anuj Dubey

If you set display_errors=off then all types of error will of.

如果您设置 display_errors=off 那么所有类型的错误都会发生。

But if you only want to notice error off the you can set error_reporting = E_ALL & ~E_NOTICE

但是如果你只想注意到错误,你可以设置 error_reporting = E_ALL & ~E_NOTICE