使用命令行方式运行PHP总是出现两次错误提示,在浏览器中则只显示一条并且显示的是下面的第二条。
PHP Fatal error: Cannot use object of type stdClass as array in E:\document\wwwroot\data\app\model\afe\gather\iTunesModel.php on line 100
Fatal error: Cannot use object of type stdClass as array in E:\document\wwwroot\data\app\model\afe\gather\iTunesModel.php on line 100
php版本:
PHP 5.3.10 (cli) (built: Feb 2 2012 20:27:51)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
提示两次错误很不爽,最后在http://stackoverflow.com/questions/9001911/why-are-php-errors-printed-twice找到了答案,原因是开启了log_errors = On但是没有指定log的位置所以log_errors就跑到了标准输出中,设置log_errors=off解决问题。浏览器访问只显示一条错误信息因为php-fpm中制定了error_log的位置,而且php-fpm中的这个优先级比php.ini的高,如下:
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M