zzengineer / eprint
Kernighan 风格的 eprint PHP 工具函数
0.9
2015-09-21 21:52 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-10-02 10:24:56 UTC
README
Kernighan 风格的 eprint PHP 工具函数
名称
eprint -- 格式化标准错误打印工具函数
概要
function eprint($msg)
function nprint($msg)
function wprint($msg)
描述
所有函数都会将消息打印到 STDERR
,前置日期、文件名、进程ID和函数使用的级别。eprint() 函数还会额外通过 exit(2)
停止执行。如果 $msg
传递为多行字符串,则将其缩进以强调其多行性质。
示例
以下代码
nprint('this is a notice'); nprint('this is a dump of the $_ENV '. print_r($_ENV, true)); wprint('this should be checked sometime'); eprint('and this will stop the execution');
将输出
2015-09-21 19:35:55 printme [81662] notice: this is a notice
2015-09-21 19:35:55 printme [81662] notice: this is a dump of the $_ENV Array
(
[PAGER] => more
[EDITOR] => vi
[...]
[SHELL] => /bin/sh
[BLOCKSIZE] => K
)
2015-09-21 19:35:55 printme [81662] warning: this should be checked sometime
2015-09-21 19:35:55 printme [81662] error: and this will stop the execution