run code in 300+ PHP versions simultaneously
<?php class testClass_forSerialize implements Serializable { public function serialize() { static $count = 0; static $objectHashes = []; $ret = new \stdClass(); $serializedData = serialize($ret); $objectHash = spl_object_hash($ret); echo "loop $count: ObjectHash $objectHash Received: ".$serializedData."\n"; if (array_key_exists($objectHash, $objectHashes) == true) { echo "Object hash already exists - serialize is going to be sad.\n"; } $objectHashes[$objectHash] = $count; if (@unserialize($serializedData) === false) { printf( "borked, serialize of %s returned %s which could not be unserialized.\n", var_export($ret, true), $serializedData ); exit(0); } echo "loop $count: Returning '$serializedData'\n"; $count++; return $serializedData; } public function unserialize($data) { throw new \Exception("not relevant"); } } $list = []; for ($i=0; $i<2; $i++) { $list[] = new \testClass_forSerialize(); } $ser = serialize($list);
based on 7vCcn

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

Output for branch master
loop 0: ObjectHash 00000000641d9e20000000007249bdb2 Received: O:8:"stdClass":0:{} loop 0: Returning 'O:8:"stdClass":0:{}' loop 1: ObjectHash 00000000641d9e27000000007249bdb2 Received: O:8:"stdClass":0:{} loop 1: Returning 'O:8:"stdClass":0:{}'

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