3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public $throw_exception = false; function __sleep() { $this->throw_exception = true; return array('throw_exception'); } function __construct() { echo "construct called\n"; if ($this->throw_exception == true) { throw new Exception(); } } } $a = new foo; $x = serialize($a); $y = unserialize($x);

preferences:
34.09 ms | 402 KiB | 5 Q