php 如何关闭 xampp 中的通知报告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19938003/
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
How to turn off notice reporting in xampp?
提问by qadenza
On a remote server there is no problem, but in localhost (xampp 3.1.) I cannot turn off reporting notices.
在远程服务器上没有问题,但在 localhost (xampp 3.1.) 中我无法关闭报告通知。
<?php
$Fname = $_POST["Fname"];
...
result:
结果:
Notice: Undefined index: Fname in D:\xampp\htdocs\xx\php01\form01.php on line 6
php.ini
配置文件
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_NOTICE //shouldn't this line turn off notice reporting ?
Any suggestion ?
有什么建议吗?
采纳答案by OlivierH
Try to do a phpinfo();
just before your $Fname = $_POST["Fname"];
line. What's the error_reporting property value ? See thisor thisto understand the value displayed in the table.
尝试phpinfo();
在您的$Fname = $_POST["Fname"];
线路之前做一个。error_reporting 属性值是多少?请参阅此或此以了解表中显示的值。
If it's not what you expected, check that the property is not changed by php.
It's also possible you edited the wrong php.ini file : XAMPP tends to copy the original php.ini file and create his own. Use phpinfo();
, search for 'php.ini' string in the table : you will find the path of the php.ini file used.
如果这不是您所期望的,请检查该属性是否没有被 php 更改。也有可能您编辑了错误的 php.ini 文件:XAMPP 倾向于复制原始 php.ini 文件并创建自己的文件。使用phpinfo();
,在表中搜索'php.ini'字符串:您将找到所使用的php.ini文件的路径。
Last thing, maybe the problem is that you did not properly restarted apache after you changed php.ini file. The thing is that xamp is a distinct process of the apache service. Closing XAMP do not make apache service to be stopped, you better use XAMPP Control Panel to stop/start apache.
最后一件事,也许问题是您在更改 php.ini 文件后没有正确重新启动 apache。问题是 xamp 是 apache 服务的一个独特进程。关闭 XAMP 不会使 apache 服务停止,您最好使用 XAMPP 控制面板来停止/启动 apache。
回答by Noor
Write this code in start of your file.
将此代码写入文件的开头。
ini_set('display_errors', 0);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
Edit1
编辑1
If you did not want to use above lines then you have to write @
before $_POST
to suppress notices, like
如果您不想使用以上几行,那么您必须在@
之前编写$_POST
以抑制通知,例如
$Fname = @$_POST["Fname"];
$Fname = @$_POST["Fname"];
Edit 2
编辑 2
With this line error_reporting = E_ALL & ~E_NOTICE
also change display_errors = Off
although its bad programming practices.
这条线error_reporting = E_ALL & ~E_NOTICE
也改变了,display_errors = Off
虽然它的编程习惯不好。
回答by MikeR
If your running XAMPP and want to turn off notices (or other features):
1. Make sure your editing the right INI file (select config from the control panel)
2. Turn display_errors=on
3. Turn error_reporting=E_ALL & ~E_NOTICE (This will only suppress notice errors)
4. Important- Make sure XAMPP is not overriding your settings further down the file (read the notice above the first set of settings)
5. Stop and Start Apache after saving the file
如果您正在运行 XAMPP 并想关闭通知(或其他功能):
1. 确保您编辑了正确的 INI 文件(从控制面板中选择配置)
2. 打开 display_errors=on
3. 打开 error_reporting=E_ALL & ~E_NOTICE (这只会抑制通知错误)
4.重要- 确保 XAMPP 没有覆盖文件下方的设置(阅读第一组设置上方的通知)
5. 保存文件后停止并启动 Apache
回答by Shashwat Singh Parihar
The most simple way to solve this problem is as follows: 1. Turn off Apache server 2. Go to c:\xampp\php\ 3. Rename php.ini to php.ini.bak 4. Rename php.ini-production to php.ini 5. Turn on the server again.
解决这个问题最简单的方法如下: 1.关闭Apache服务器 2.转到c:\xampp\php\ 3.将php.ini重命名为php.ini.bak 4.将php.ini-production重命名为php.ini 5. 再次打开服务器。
It has a flaw that it reverts everything to production mode. but you can always undo this.
它有一个缺陷,它将一切恢复到生产模式。但您可以随时撤消此操作。