PHP 5.3弃用消息显示为警告

eju*_*ker 9 php

我有一个需要register_globalsmagic_quotes_gpc启用的遗留应用程序.我有我的error_reporting设置,E_ALL & ~E_DEPRECATED因为我仍然希望看到任何警告.

当我运行PHP CLI时,我得到以下内容

$ php -d "error_reporting=E_ALL & ~E_DEPRECATED" -v
PHP Warning:  Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP 5.3.3 (cli) (built: Mar 30 2011 13:51:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)

为什么将弃用消息显示为警告?他们不应该在这个E_DEPRECATED级别吗?

似乎我不得出现让他们离开的警告

$ php -d "error_reporting=E_ALL & ~E_WARNING" -v
PHP 5.3.3 (cli) (built: Mar 30 2011 13:51:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
Run Code Online (Sandbox Code Playgroud)

我可以改变我的error_reporting,E_ALL & ~E_DEPRECATED & ~E_WARNING但它不会显示我的webapp的警告.有什么建议?我是否必须单独使用php.iniCLI?

Dus*_*rea 0

最好的做法是不使用其中任何一个。它们是E_WARNING因为这些是开发人员选择触发的错误类型(在该级别上使用一种与另一种是任意的)。

我强烈建议您确保在配置中关闭这些功能,或者如果无法避免,只需在配置中关闭这些类型的警告即可。否则,您将面临破坏 AJAX 请求的风险。我们都必须应对它。