b2r/simple-dump

v0.1.0 2017-02-20 04:21 UTC

This package is not auto-updated.

Last update: 2024-04-13 18:07:56 UTC


README

Simple var_dump wrapper

Build Status

Summary

  • Minify var_dump result
  • Register p global function : function($value...): void echo dump result
  • Register ps global function : function($value...): string get dump string

Usage

use b2r\Component\SimpleDump\SimpleDump;

// get as string
$server = SimpleDump::dump($_SERVER);

// echo
SimpleDump::display($_SERVER);

// Register global function `p` and `ps`
SimpleDump::init();

// get as string
$server = ps($_SERVER);

// echo
p($_SERVER);

Comparison

// Register global function `p` and `ps`
b2r\Component\SimpleDump\SimpleDump::init();

# Store
$value = [
    'string' => 'string',
    'int'    => 1,
    'float'  => 1.0,
    'true'   => true,
    'false'  => false,
    'null'   => null,
];
$value['object'] = (object)$value;

# Echo
echo "------------------------------------------------------------\n";
p($value);
echo "------------------------------------------------------------\n";
var_dump($value);

result

------------------------------------------------------------
array(7) {
  ["string"]=> string(6) "string"
  ["int"]=> int(1)
  ["float"]=> float(1)
  ["true"]=> bool(true)
  ["false"]=> bool(false)
  ["null"]=> NULL
  ["object"]=> object(stdClass)#3 (6) {
    ["string"]=> string(6) "string"
    ["int"]=> int(1)
    ["float"]=> float(1)
    ["true"]=> bool(true)
    ["false"]=> bool(false)
    ["null"]=> NULL
  }
}
------------------------------------------------------------
array(7) {
  ["string"]=>
  string(6) "string"
  ["int"]=>
  int(1)
  ["float"]=>
  float(1)
  ["true"]=>
  bool(true)
  ["false"]=>
  bool(false)
  ["null"]=>
  NULL
  ["object"]=>
  object(stdClass)#3 (6) {
    ["string"]=>
    string(6) "string"
    ["int"]=>
    int(1)
    ["float"]=>
    float(1)
    ["true"]=>
    bool(true)
    ["false"]=>
    bool(false)
    ["null"]=>
    NULL
  }
}