PHP code example of edwardstock / superserializer

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

    

edwardstock / superserializer example snippets



use edwardstock\superserializer\Serializer;

$o       = new \stdClass();
$o->func = function () {};

$o2       = new \stdClass();
$o2->prop = [
    'k' => function () {
        },
];

$values = [
    'integer'     => 1,
    'float'       => 111.111,
    'object'      => new \stdClass(),
    'array'       => ['k' => 'v'],
    'array_with_closure'  => [
        'k' => function () {
        },
    ],
    'object_with_closure' => $o,
    'bool_true'           => true,
    'bool_false'          => false,
    'null'        => null,
];

$ser1 = Serializer::serialize($o);
$ser2 = Serializer::serialize($o2);
$ser3 = Serializer::serialize($values);

// $o1
$unser1 = Serializer::unserialize($ser1);

// $o2
$unser2 = Serializer::unserialize($ser2);

// $values
$unser3 = Serializer::unserialize($ser3);