关闭 PHP.ini 文件 WAMP 中的弃用警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24559842/
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
Turning off Deprecation warnings in PHP.ini file WAMP
提问by Javacadabra
I am working on project @ home and using WAMP for development. Currently the php.ini
file has the following lines set like this:
我正在从事项目@home 并使用 WAMP 进行开发。目前,该php.ini
文件具有如下设置:
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
I had hoped in doing so it would prevent deprecation warnings from showing up. However it is not. Is there a way I can adjust error_reporting
to ignore deprecated warnings.
我曾希望这样做可以防止出现弃用警告。然而事实并非如此。有没有一种方法可以调整error_reporting
以忽略已弃用的警告。
Output I am getting currently:
我目前得到的输出:
回答by A-312
You can use this function :
您可以使用此功能:
error_reporting(E_ALL ^ E_DEPRECATED);
http://www.php.net/manual/en/function.error-reporting.php
http://www.php.net/manual/en/function.error-reporting.php
Or use "@" operator before function name.
或者在函数名前使用“@”运算符。
@mysql_connect();
回答by Ryan Augustine
In your php.ini file change the following.. (note wamp has 2 different php.ini files so make the changes on both)
在您的 php.ini 文件中更改以下内容..(注意 wamp 有 2 个不同的 php.ini 文件,因此对两者进行更改)
from this
由此
error_reporting = E_ALL
to this
对此
error_reporting = E_ALL & ~E_DEPRECATED
回答by n-dru
I had the same problem. It turned out however, that I edited wrong php.ini
file. In my case the correct one was
我有同样的问题。然而,事实证明,我编辑了错误的php.ini
文件。就我而言,正确的是
C:\wamp64\bin\php\php5.6.25\phpForApache.ini
C:\wamp64\bin\php\php5.6.25\phpForApache.ini
and in this file I have changed this line to:
在此文件中,我已将此行更改为:
error_reporting = E_ALL & ~E_DEPRECATED
.
error_reporting = E_ALL & ~E_DEPRECATED
.
It didn't make any difference what I had changed in that "obvious" php.ini
file.
我在那个“明显”php.ini
文件中所做的更改没有任何区别。
回答by Gergo Erdosi
If you want to show all errors except deprecated, then use this setting:
如果要显示除已弃用之外的所有错误,请使用此设置:
error_reporting = E_ALL ^ E_DEPRECATED
Edit:You could also create a custom error handler to hide only mysql_
deprecation warnings:
编辑:您还可以创建自定义错误处理程序以仅隐藏mysql_
弃用警告:
set_error_handler(function($errno, $errstr) {
return strpos($errstr, 'mysql_') === 0;
}, E_DEPRECATED);
But please note that mysql_
functions are deprecated. So instead of trying to hide the errors, consider switching to mysqli
or PDO
.
回答by Ramesh Kumar
To hide php errors on WAMP server, Please open php.inifile and find following line of code
要在 WAMP 服务器上隐藏 php 错误,请打开php.ini文件并找到以下代码行
error_reporting = E_ALL
and replace it with
并将其替换为
error_reporting = E_ALL & ~E_NOTICE
All errors will be hide/disable.
所有错误都将被隐藏/禁用。
回答by seyi_php
Set your error report to
将错误报告设置为
error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
错误报告(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
on your php page.
在您的 php 页面上。