alddesign / php-xout

此包的最新版本(1.0.0)没有提供许可信息。

PHP的var_dump()函数的更易读实现

1.0.0 2024-07-19 21:47 UTC

This package is auto-updated.

Last update: 2024-09-19 22:22:03 UTC


README

PHP的var_dump()print_r()函数的更易读、语法高亮实现。
兼容所有回退到5.4版本的PHP版本

安装

通过Composer

composer require alddesign/php-xout

手册

下载包并加载xout.php

require_once 'xout.php'

用法

//code before...
$array = 
[
    'cars' => ['audi','bmw','volkswagen'], 
    'settings' => (object)
    [
        'drive' => true, 
        'disable_car' => 
        function(){}
    ],
    'value' => 220.25,
    'active' => null
];

//Call xout
Xout::xout($array);

//Or use the shorthand function:
xout($var);

输出将看起来像这样
output

备注

参数

  • value:要输出的表达式
  • return (bool):如果设置为true,则返回结果html而不是输出它。默认:false
  • dontDie (bool):如果设置为true,则脚本不会终止。当return设置为true时,此参数没有作用。默认:false

自定义

xout.php中,您可以更改许多选项,如字体、颜色、括号样式等。