jeremykendall / debug-die
方便包装的var_dump()和die(var_dump())
0.0.1
2015-01-12 17:58 UTC
Requires
- php: >=5.3.2
This package is auto-updated.
Last update: 2024-08-25 06:20:05 UTC
README
Debug Helper是一组方便的函数,用于包装var_dump()
和die(var_dump())
。因为懒惰。
安装
使用Composer安装Debug Helper。
{
"require": {
"jeremykendall/debug-die": "*"
}
}
d()和dd()
d()
和dd()
分别包装var_dump()
和die(var_dump())
,这两个函数都使用与var_dump()
相同的函数签名,这意味着你可以向函数传递多个参数,每个参数都会单独打印。
void d ( mixed $expression [, mixed $... ] )
void dd ( mixed $expression [, mixed $... ] )
示例用法可在example.php中查看。
<?php require_once './vendor/autoload.php'; $one = array('one', 'two', 'three'); $two = 'String argument'; d('debug', $one, $two); dd('debug and die', $one, $two); echo "You'll never see me.";
示例可以从命令行执行
$ php -f example.php
string(5) "debug"
array(3) {
[0] =>
string(3) "one"
[1] =>
string(3) "two"
[2] =>
string(5) "three"
}
string(15) "String argument"
string(13) "debug and die"
array(3) {
[0] =>
string(3) "one"
[1] =>
string(3) "two"
[2] =>
string(5) "three"
}
string(15) "String argument"
建议
在我看来,var_dump()
最好与Xdebug结合使用。你应该在开发中使用Xdebug,所以现在就去安装它。现在就去。