PHP code example of agashe / var-dumper

1. Go to this page and download the library: Download agashe/var-dumper 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/ */

    

agashe / var-dumper example snippets




ta 1", "data 2");

d(null , 10.59, true);

dump(null , 10.59, true);

class Foo {
    public $name;
    private $age;
}

$foo = new Foo();
$foo->name = "hello world";

dump_to_file(__DIR__ . '/path/to/dump.txt' , $foo);

d('ahmed', 5.6, false, M_PI, NULL);
dump_to_file(__DIR__ . 'data.txt', 'ahmed', 5.6, false, M_PI, NULL);
dump_to_file(__DIR__ . 'data.json', 'ahmed', 5.6, false, M_PI, NULL);

{
    "dump_712db6d": {
        "timestamp": {
            "time": "11-01-2024 09:51:28",
            "file": "index.php",
            "line": 7
        },
        "data": {
            "string (5)": "ahmed",
            "double": 3.1415926535898,
            "boolean": "false",
            "value": null
        }
    }
}

{
    "dump_82c13d8": {
        "timestamp": {
            "time": "11-01-2024 11:06:49",
            "file": "index.php",
            "line": 17
        },
        "data": {
            "RegExp (17)": "\/^([A-Za-z1-9])$\/"
        }
    },
    "dump_716e868": {
        "timestamp": {
            "time": "11-01-2024 11:06:49",
            "file": "index.php",
            "line": 18
        },
        "data": {
            "Serializable (30)": "a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}"
        }
    },
    "dump_8a02891": {
        "timestamp": {
            "time": "11-01-2024 11:06:49",
            "file": "index.php",
            "line": 19
        },
        "data": {
            "URL (25)": "http:\/\/www.helloworld.com"
        }
    },
    "dump_3d24331": {
        "timestamp": {
            "time": "11-01-2024 11:06:49",
            "file": "index.php",
            "line": 20
        },
        "data": {
            "Email (16)": "[email protected]"
        }
    },
    "dump_47530be": {
        "timestamp": {
            "time": "11-01-2024 11:06:49",
            "file": "index.php",
            "line": 21
        },
        "data": {
            "Date\/Time (9)": "20-5-1995"
        }
    }
}

$class = new class
{
    public $name;

    public function __construct()
    {
        $this->name = 'omar';
    }
};

d($class);
dump_to_file(__DIR__ . '/data.txt', $class);
dump_to_file(__DIR__ . '/data.json', $class);

$arr = [
    'a' => 'apple',
    'b' => 'banana',
    'c' => [1, 2, [1, 2, 3]],
    'd' => 'dates',
];

d($arr);
dump_to_file(__DIR__ . '/data.txt', $arr);
dump_to_file(__DIR__ . '/data.json', $arr);

[ Time : 11-01-2024 11:31:48 / File : index.php / Line : 12 ] 

array (4) => [
    a => "apple"
    b => "banana"
    [c] array (3) => [
        0 => 1
        1 => 2
        [2] array (3) => [
            0 => 1
            1 => 2
            2 => 3
        ]
    ]
    d => "dates"
]

{
    "dump_431b83a": {
        "timestamp": {
            "time": "11-01-2024 11:31:48",
            "file": "index.php",
            "line": 13
        },
        "data": {
            "array (4)": {
                "a": "apple",
                "b": "banana",
                "[c] array (3)": {
                    "0": 1,
                    "1": 2,
                    "[2] array (3)": {
                        "0": 1,
                        "1": 2,
                        "2": 3
                    }
                },
                "d": "dates"
            }
        }
    }
}

$file = fopen(__DIR__ . '/something.txt', 'r');

d($file);
dump_to_file(__DIR__ . '/data.txt', $file);
dump_to_file(__DIR__ . '/data.json', $file);

{
    "dump_caf8a63": {
        "timestamp": {
            "time": "11-01-2024 11:37:00",
            "file": "index.php",
            "line": 8
        },
        "data": {
            "Resource id #12": {
                "timed_out": "false",
                "blocked": "true",
                "eof": "false",
                "wrapper_type": "plainfile",
                "stream_type": "STDIO",
                "mode": "r",
                "unread_bytes": 0,
                "seekable": "true",
                "uri": "\/path\/to\/something.txt",
                "[options] array (0)": {}
            }
        }
    }
}

$closure = function ($name, $age = '') {
    return $name;
};

d($closure);
dump_to_file(__DIR__ . '/data.txt', $closure);
dump_to_file(__DIR__ . '/data.json', $closure);

$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris viverra at est sed vestibulum. Ut ultricies urna et bibendum sollicitudin. Maecenas suscipit bibendum ante convallis dignissim. Nulla facilisi. Sed mollis eget purus eget finibus.Donec convallis risus sit amet dapibus vehicula. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum vel aliquet ante. Suspendisse vitae neque non nulla viverra blandit at at diam. Phasellus imperdiet quis lacus sed facilisis. Mauris lacinia arcu lorem, quis commodo arcu fringilla in.";


d($text);
dump_to_file(__DIR__ . '/data.txt', $text);
dump_to_file(__DIR__ . '/data.json', $text);