PHP Classes

File: demo/demo.php

Recommend this page to a friend!
  Classes of Rodolfo Berrios Arce   Var-Dump   demo/demo.php   Download  
File: demo/demo.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Var-Dump
Show the value of a variable in colored way
Author: By
Last change:
Date: 1 month ago
Size: 1,137 bytes
 

Contents

Class file image Download
<?php

/*
 * This file is part of Chevere.
 *
 * (c) Rodolfo Berrios <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

use
Chevere\Writer\StreamWriter;
use function
Chevere\VarDump\varDumpConsole;
use function
Chevere\VarDump\varDumpHtml;
use function
Chevere\VarDump\varDumpPlain;
use function
Chevere\Writer\streamTemp;

require_once
__DIR__ . '/../vendor/autoload.php';

foreach ([
   
'console.log' => varDumpConsole(),
   
'plain.txt' => varDumpPlain(),
   
'html.html' => varDumpHtml(),
] as
$filename => $varDump) {
   
$writer = new StreamWriter(streamTemp(''));
   
$varDump
       
->withVariables($varDump)
        ->
process($writer);
   
$dumping = str_replace(
       
__DIR__,
       
'/var/www/html',
       
$writer->__toString()
    );
    if (
PHP_SAPI === 'cli') {
        if (
$filename === 'console.log') {
            echo
$dumping;
        }
    } elseif (
$filename === 'html.html') {
        echo
$dumping;
    }
   
file_put_contents(__DIR__ . '/output/' . $filename, $dumping);
}