tomi20v/echop

PHP的格式化打印工具

1.3.2 2015-03-26 23:49 UTC

This package is not auto-updated.

Last update: 2024-09-24 08:43:06 UTC


README

=====

PHP的全功能格式化打印工具。

比print_r或var_dump更简洁、信息丰富的格式。还打印可访问的静态属性和常量。支持详细的HTML格式或简洁的终端格式,可选地包含phpdoc信息。

有一些绑定在单独的文件中,可以包含,以便您使用最简单的打印命令

从源代码

/**
 * the pretty printer
 * 	I will print all kinds of data in a condensed but nice format
 * 	I will print constants and static properties of objects as well
 * 	I will detect cycle references in objects (but not in arrays)
 * 	I will stop at a certain depth level so array recursion is caught as well
 * @param mixed $param I will print this nicely
 * @param boolean $returnOnly if true, I only return in a string, otherwise I print
 * @param int $indent what I print will be indented this much
 * @param int $maxDepth print no deeper than this but print *DEPTH LIMIT* instead. 0 means no limit
 * @param boolean $isHtml if true I'll do some HTML formatting (<pre> and <b> tags )
 * @param boolean $phpDoc if true, it will look for phpdoc tags of all properties etc
 * @return string|void
 */

带有所有额外信息的示例输出

MyClass Object (
    const [**MAP_C**] => 2
    /** @var string this is the first variable */
    static [**pus**:public] => string(3) **pus**
    /** @var string this is the second variable */
    static [**_prs**:protected] => string(3) **prs**
    /** @var string this is my protected property */
    [**_pro**:protected] => string(3) **pro**
    /** @var string this is another protected property */
    [**_pro2**:protected] => string(3) **pro2**
    /** @var string and finally public */
    [**pu**:public] => string(2) **pu**
)

变更日志

1.3.2 2015-03-26 修复composer.json,一些美化,升级

1.3.1 2014-09-05 在composer.json中添加类型库

1.3 2014-09-05 使Packagist友好,添加了新的绑定"echon",它总是返回打印输出

1.2 2014-08-20 添加许可证:修复了不递归传递$phpDoc参数的问题,函数现在在单独的文件中

1.1 2012-11-11 将echop()移动到EchoPrinter类中,以便封装它及其工具可以查找并打印变量的PhpDoc注释

1.0 2012-10-17 初始版本

为什么?

我的第一个echop()实现只是包装了print_r,可选的第二参数值为2,使得脚本能够打印并退出。我上瘾了,因为我可以用比print_r或var_dump更快的速度写出"echop"这个词... 这是在15年前。从那时起,它有所发展,最近还服务于一些实验,比如'在composer上放些东西'。