- unserialize: documentation ( source)
- serialize: documentation ( source)
- printf: documentation ( source)
<?php
class A{
public $a;
public function __construct($a) { $this->a = $a; }
public function __wakeup() {
printf("Calling wakeup, a=%d\n", $this->a);
if ($this->a === 3) {
throw new Exception("wakeup threw exception");
}
}
}
$x = [new A(1), new A(2), new A(3), new A(4), new A(5)];
unserialize(serialize($x));