关闭 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:22:07  来源:igfitidea点击:

Turning off Deprecation warnings in PHP.ini file WAMP

php

提问by Javacadabra

I am working on project @ home and using WAMP for development. Currently the php.inifile 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_reportingto ignore deprecated warnings.

我曾希望这样做可以防止出现弃用警告。然而事实并非如此。有没有一种方法可以调整error_reporting以忽略已弃用的警告。

Output I am getting currently:

我目前得到的输出:

Screen of the problem

问题画面

回答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.inifile. 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.inifile.

我在那个“明显”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 mysqlior PDO.

但请注意,mysql_函数已被弃用。因此,与其试图隐藏错误,不如考虑切换到mysqliPDO

回答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 页面上。