3v4l.org

run code in 300+ PHP versions simultaneously
<?php class niet { protected $one; protected $two; protected $three; protected $four; public function __construct() { $this->one = "1"; $this->two = "2"; $this->three = "3"; $this->four = "4"; } public function getData() { return [$this->one, $this->two, $this->three, $this->four]; } } class wel extends niet implements Serializable { public function serialize() { return serialize($this->getData()); } public function unserialize($data) { list($this->one, $this->two, $this->three, $this->four) = unserialize($data); } } $obj = new obj; $ser = serialize($obj); var_dump($ser); $newobj = unserialize($ser); var_dump($newobj->getData()); ?>

preferences:
39.28 ms | 402 KiB | 5 Q