3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ab implements Serializable{ protected $x; function __construct() { $this->x = 'val'; } public function serialize() { throw new Exception('Can\'t serialize '); } public function unserialize($str) { throw new Exception('Can\'t serialize '); } } try{ $tmp = serialize(new Ab()); }catch(Exception $e){ var_dump($e); }

preferences:
39.01 ms | 402 KiB | 5 Q