ghostff / dump5
php var_dump 的美化版本。该类显示一个或多个表达式的结构化信息,包括其类型和值。
2.0.1
2020-08-10 17:42 UTC
Requires
- php: >=5.3
This package is auto-updated.
Last update: 2024-09-23 18:37:52 UTC
README
php var_dump 的美化版本。该类显示一个或多个表达式的结构化信息,包括其类型和值。
查看 Dump7 以支持 PHP 7+
安装
您可以下载最新的 发布版本 作为独立文件,或者您可以使用 Composer
composer require ghostff/dump5
"require": { "ghostff/dump5": "^1.0" }
显示标志
您可以使用文档块标志简单地隐藏或显示某些对象的属性
/** * @dumpignore-inheritance * @dumpignore-inherited-class * @dumpignore-private * @dumpignore-public * @dumpignore-public */ Class Foo extends Bar { /** @dumpignore */ public $big_object = null; }
用法
class FooBar { private $inherited_int = 123; private $inherited_array = array('string'); } class Bar extends FooBar { private $inherited_float = 0.22; private $inherited_bool = true; } class Foo extends Bar { private $string = 'string'; protected $int = 10; public $array = array( 'foo' => 'bar' ); protected static $bool = false; } $string = 'Foobar'; $array = array('foo', 'bar'); $int = 327626; $double = 22.223; $null = null; $bool = true; $resource = fopen('LICENSE', 'r'); $m = microtime(true); new Dump(new Foo, $string, $array, $int, $double, $null, $bool, array( 'foo' => 'bar', 'bar' => 'foo', array( 'foo' => 'foobar', 'bar_foo', 2 => 'foo', 'foo' => array( 'barbar' => 55, 'foofoo' => false, 'foobar' => null, ) ) ), $resource); new Dump(1 == '1', 1 === '1');
替换预定义的颜色
# set($name, [$cgi_color, $cli_color]); Dump::set('boolean', array('bb02ff', 'purple'));
CGI 输出
CLI Posix 输出
使用命令行工具如 cmder
的 Windows 用户可以使用 Dump::d
方法
Dump::d(new Foo, $string, $array, $int, $double, $null, $bool, array( 'foo' => 'bar', 'bar' => 'foo', array( 'foo' => 'foobar', 'bar_foo', 2 => 'foo', 'foo' => array( 'barbar' => 55, 'foofoo' => false, 'foobar' => null, ) ) ));
CLI Windows 输出