run code in 300+ PHP versions simultaneously
<?php class testClass_forSerialize implements Serializable{ public function serialize() { // use array instead of stdClass $ret = Array(); foreach($this as $k=>$v){ if ($v!==null) { $ret[$k] = $v; } } $serializedData = serialize($ret); if (unserialize($serializedData)===false) { var_dump($serializedData); throw new \Exception("Serialize failed"); } return $serializedData; } public function unserialize($data) { $dataObj = unserialize($data); foreach($dataObj as $k=>$v) { $this->{$k} = $v; } } } class testClass_forSerialize_02 extends \testClass_forSerialize{ public $list = Array(); public function __construct() { for ($i=0; $i<10; $i++) { $this->list[] = new \testClass_forSerialize(); } } } $obj = new \testClass_forSerialize_02(); $ser = serialize($obj); $obj2 = unserialize($ser);

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for branch master

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page