错误报告开启详细实现,安装Ecshop首页现身报错

定义和用法
error_reporting() 设置 php 的报错级别并返回当前级别。

出现下面这就话:

语法
error_reporting(report_level)如果参数 level 未指定,当前报错级别将被返回。下面几项是 level 可能的值

Strict Standards: Only variables should be passed by reference in E:ToolsECShop_V2.7.3_UTF8_release1106uploadincludescls_template.php
on line 418
第418行:$tag_sel = array_shift(explode(' ', $tag));

解决办法 1 
5.3以上版本的问题,应该也和配置有关 只要418行把这一句拆成两句就没有问题了  $tag_sel = array_shift(explode(' ', $tag)); 改成: $tag_arr = explode(' ', $tag);  $tag_sel = array_shift($tag_arr);
(实验过,绝对可行) 因为array_shift的参数是引用传递的,5.3以上默认只能传递具体的变量,而不能通过函数返回值 
解决办法 2 : 或则如果这样配置的话: error_reporting = E_ALL | E_STRICT

*/
//关闭所有的错误报告
error_reporting(0);
//只报告运行错误
error_reporting(e_error|e_warning|e_parse);
//报告e_notice
error_reporting(e_error|e_warning|e_parse|e_notice);
//报告所有的运行错误,除了e_notice
//这是php.ini的默认值
error_reporting(e_all ^ e_notice);
//报告所有的php错误
error_reporting(e_all);
//和error_reporting(e_all)有一样的功效,该设置也会报告所有php错误
ini_set('error_reporting', e_all);

php.ini中有如下设置:

/*

error_reporting = E_ALL | E_STRICT

值 常量 描述
1 e_error fatal run-time errors. errors that can not be recovered from. execution of the script is halted
2 e_warning non-fatal run-time errors. execution of the script is not halted
4 e_parse compile-time parse errors. parse errors should only be generated by the parser
8 e_notice run-time notices. the script found something that might be an error, but could also happen when running a script normally
16 e_core_error fatal errors at php startup. this is like an e_error in the php core
32 e_core_warning non-fatal errors at php startup. this is like an e_warning in the php core
64 e_compile_error fatal compile-time errors. this is like an e_error generated by the zend scripting engine
128 e_compile_warning non-fatal compile-time errors. this is like an e_warning generated by the zend scripting engine
256 e_user_error fatal user-generated error. this is like an e_error set by the programmer using the php function trigger_error()
512 e_user_warning non-fatal user-generated warning. this is like an e_warning set by the programmer using the php function trigger_error()
1024 e_user_notice user-generated notice. this is like an e_notice set by the programmer using the php function trigger_error()
2048 e_strict run-time notices. php suggest changes to your code to help interoperability and compatibility of the code
4096 e_recoverable_error catchable fatal error. this is like an e_error but can be caught by a user defined handle (see also set_error_handler())
8191 e_all all errors and warnings, except level e_strict (e_strict will be part of e_all as of php 6.0)

 

*/

这是说,显示那些不符合编码规范的警告(coding standards warnings)。

function unserialize_handler($errno,$errstr)     //自定义函数
{
  echo "invalid serialized value.n";       //输出指定内容
}
$serialized='foo';          //定义字符串
set_error_handler('unserialize_handler');      //设置用户自定义错误信息函数
$original=unserialize($serialized);       //从已存储的表示中创建php的值
restore_error_handler();         //恢复错误信息指针

 

Joomla其实是建议取消error的输出,如果出于调试需要,应改为

error_reporting = E_ALL & ~E_NOTICE

 

问题得到解决。

 

下面是错误输出配置的原文:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Error handling and logging ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

; This directive informs PHP of which errors, warnings and notices you would like

; it to take action for. The recommended way of setting values for this

; directive is through the use of the error level constants and bitwise

; operators. The error level constants are below here for convenience as well as

; some common settings and their meanings.

; By default, PHP is set to take action on all errors, notices and warnings EXCEPT

; those related to E_NOTICE and E_STRICT, which together cover best practices and

; recommended coding standards in PHP. For performance reasons, this is the

; recommend error reporting setting. Your production server shouldn't be wasting

; resources complaining about best practices and coding standards. That's what

; development servers and development settings are for.

; Note: The php.ini-development file has this setting as E_ALL | E_STRICT. This

; means it pretty much reports everything which is exactly what you want during

; development and early testing.

;

; Error Level Constants:

; E_ALL            - All errors and warnings (includes E_STRICT as of PHP 6.0.0)

; E_ERROR          - fatal run-time errors

; E_RECOVERABLE_ERROR  - almost fatal run-time errors

; E_WARNING        - run-time warnings (non-fatal errors)

; E_PARSE          - compile-time parse errors

; E_NOTICE          - run-time notices (these are warnings which often result

;                   from a bug in your code, but it's possible that it was

;                   intentional (e.g., using an uninitialized variable and

;                   relying on the fact it's automatically initialized to an

;                   empty string)

; E_STRICT          - run-time notices, enable to have PHP suggest changes

;                   to your code which will ensure the best interoperability

;                   and forward compatibility of your code

; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup

; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's

;                   initial startup

; E_COMPILE_ERROR  - fatal compile-time errors

; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)

; E_USER_ERROR      - user-generated error message

; E_USER_WARNING    - user-generated warning message

; E_USER_NOTICE    - user-generated notice message

; E_DEPRECATED      - warn about code that will not work in future versions

;                   of PHP

; E_USER_DEPRECATED - user-generated deprecation warnings

;

; Common Values:

;  E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)

;  E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)

;  E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)

;  E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)

; Default Value: E_ALL & ~E_NOTICE    ------默认

; Development Value: E_ALL | E_STRICT  ------开发用

; Production Value: E_ALL & ~E_DEPRECATED -- 正式发布用

;

;error_reporting = E_ALL | E_STRIC

本文由365bet体育在线官网发布于365bet,转载请注明出处:错误报告开启详细实现,安装Ecshop首页现身报错

TAG标签:
Ctrl+D 将本页面保存为书签,全面了解最新资讯,方便快捷。