标签:模拟 事件 错误处理 .net 函数返回 syslog any odi standard
一、错误处理
a) 错误报告级别
b) 调整错误报告级别
E_ERROR 1 致命的运行时错误(阻止代码执行)
E_WARNING 2 运行时警告
E_NOTICE 8 运行时注意
E_ALL 所有的错误 警告的注意信息
c) trigger_error 代替die()
trigger_error 可以模拟一个报错信息输出
d) 自定义错误处理
1.屏蔽错误
1.
ini_set() 设置php.ini中的配置项
ini_get() 获取php.ini中的配置项
2.
error_reporting() 设置错误报告级别
E_ALL^E_NOTICE
E_ALL^E_NOTICE^E_WARNING
3.手动修改错误
a) ; Possible Values:
b) ; Off = Do not display any errors
c) ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
d) ; On or stdout = Display errors to STDOUT
e) ; Default Value: On
f) ; Development Value: On
g) ; Production Value: Off
h) ; http://php.net/display-errors
i) display_errors = On 将on 改成off屏蔽错误
或者
; Common Values:
; E_ALL (Show all errors, warnings and notices including coding standards.)
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting =E_ALL & ~E_NOTICE
2.自定义错误日志
error_log() 使用指定的文件记录错误报告日志
error_log写入wamp下面的php日志中
; Log errors to specified file. PHP‘s default behavior is to leave this value
; empty.
; http://php.net/error-log
; Example:
error_log ="c:/wamp/logs/php_error.log"
; Log errors to syslog (Event Log on Windows).
;error_log = syslog
3.以下几种情况可以考虑自定义错误处理
a) 可以记下错误信息 及时发现一些生产环境出现的问题
b) 可以屏蔽错误
c) 可以控制错误的输出
d) 可以作为调试工具
二、时间函数
自从Unix纪元(格林威治时间1970年1月1日 00:00:00)到现在的秒数
time() 函数返回一个当前系统的时间戳
date() 有两个参数 第一个参数是要以什么格式输出 第二个参数是时间戳
返回将整数时间戳 按照给定的格式字符串而产生字符串 如果没有给出时间戳则使用本地当前时间戳 换句话来说就是时间戳可选 如果没有就默认当前时间戳
mktime取的一个日期的unix时间戳
mktime(时,分,秒,月,日,年)
date_default_timezone_set() 设置时区
参数值:
PRC 中华人民共和国
Asia/Shanghai 亚洲/上海
Asia/ChongQing 亚洲/重庆
Asia/Hong_Kong 亚洲/香港
date_default_timezone_get() 获取时区
strtotime() 将任何英文文本的日期和时间描述成时间戳
//unix时间戳的有效期
//2147483647
echo ‘<br/>‘;
echo date(‘Y-m-d H:i:s‘,‘2147483647‘);
标签:模拟 事件 错误处理 .net 函数返回 syslog any odi standard
原文地址:http://www.cnblogs.com/ygsjm/p/7425499.html