环境: wamp+php5+mysql
问题描述:在本地调试php代码的时候,升级了php版本(5.5.12), 爆出大量WARNING, DEPRECATED,NOTICE提示。
第一次修改:
修改方案: 由于只是本地调试用的,修改之前的代码不划算,所以准备隐藏错误。在php.ini里面进行更改error_reporting=E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING;
修改结果: 不出所料,不起作用
第二次修改:
修改方案:
(居然在百度上找到资料,根据提示,进入了stackoverflow里面找到了答案,原来是需要修改apache的配置。)http://stackoverflow.com/questions/5628148/disable-e-deprecated-in-php-error-log进入apache的配置文件, httpd.conf,由于我的是php 5 .5.12, 所以在末尾加上
自问自答:
24565是什么东西?
它就是E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING
E_ALL, E_NOTICE这些东西是常量,&,~是按位与和取反 操作,在脚本里面echo E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING; 就是24565,http://www.php.net/manual/en/errorfunc.constants.php。
如果知道24565,那么如何知道是什么级别报错呢?
抄过来的代码:
$error_number = 24565; $error_description = array( ); $error_codes = array( E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_PARSE => "E_PARSE", E_NOTICE => "E_NOTICE", E_CORE_ERROR => "E_CORE_ERROR", E_CORE_WARNING => "E_CORE_WARNING", E_COMPILE_ERROR => "E_COMPILE_ERROR", E_COMPILE_WARNING => "E_COMPILE_WARNING", E_USER_ERROR => "E_USER_ERROR", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_STRICT => "E_STRICT", E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", E_DEPRECATED => "E_DEPRECATED", E_USER_DEPRECATED => "E_USER_DEPRECATED", E_ALL => "E_ALL" ); foreach( $error_codes as $number => $description ) { if ( ( $number & $error_number ) == $number ) { $error_description[ ] = $description; } } echo sprintf( "error number %d corresponds to:\n%s", $error_number, implode( " | ", $error_description ) );
摘自: https://stackoverflow.com/questions/4678082/what-is-22527-in-error-reporting-22527-of-phpinfo
打印出来没有E_NOTICE,E_DEPRECATED和E_WARNING。