PHP code example of danog / magicalserializer
1. Go to this page and download the library: Download danog/magicalserializer 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/ */
danog / magicalserializer example snippets
class a
{
public function __construct() {
var_dump("Constructed!");
$this->a = 'pony';
}
public function __wakeup() {
var_dump($this->a);
}
}
$a = new a;
file_put_contents('test', serialize($a));
class a extends \Volatile
{
use \danog\Serializable;
public function __magic_construct() {
var_dump("Constructed!");
$this->a = 'pony';
}
public function __wakeup() {
var_dump($this->a);
}
}
$a = \danog\Serialization::unserialize(file_get_contents('test'));
var_dump($a);
$othera = new a;