PHP code example of 1tomany / pretty-print
1. Go to this page and download the library: Download 1tomany/pretty-print library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
1tomany / pretty-print example snippets
use function OneToMany\PrettyPrint\pretty_print;
var_dump(pretty_print(null)); // string(4) "null"
var_dump(pretty_print(true)); // string(4) "true"
var_dump(pretty_print(false)); // string(5) "false"
var_dump(pretty_print(0)); // string(1) "0"
var_dump(pretty_print(1.0)); // string(3) "1.0"
var_dump(pretty_print(\M_PI)); // string(15) "3.1415926535898"
var_dump(pretty_print('PHP')); // string(5) ""PHP""
var_dump(pretty_print([])); // string(2) "[]"
var_dump(pretty_print(['A', 'B'])); // string(10) "["A", "B"]"
var_dump(pretty_print(['name' => 'Vic'])); // string(15) "[name => "Vic"]"
var_dump(pretty_print(new \DateTimeImmutable())); // string(25) "2026-03-03T17:36:40+00:00"
var_dump(pretty_print('This string is longer than 32 characters', 32)); // string(37) ""This string is longer than 32 ch...""
var_dump(pretty_print(\fopen('file.txt', 'r'))); // string(7) "unknown"