3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $user = new stdClass(); $user->id = 1; $user->name = 'John Doe'; class Herman { private $milk; public function setMilk($flag) { $this->milk = $flag; } } $hermit = new Herman(); $hermit->setMilk(true); $user->hermit = $hermit; $foobar = array('foo' => 'bar', 'user' => $user); $serialized = serialize($foobar); echo "Serialized: ${serialized}"; var_dump(unserialize($serialized));
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Serialized: a:2:{s:3:"foo";s:3:"bar";s:4:"user";O:8:"stdClass":3:{s:2:"id";i:1;s:4:"name";s:8:"John Doe";s:6:"hermit";O:6:"Herman":1:{s:12:"Hermanmilk";b:1;}}}array(2) { ["foo"]=> string(3) "bar" ["user"]=> object(stdClass)#3 (3) { ["id"]=> int(1) ["name"]=> string(8) "John Doe" ["hermit"]=> object(Herman)#4 (1) { ["milk":"Herman":private]=> bool(true) } } }
Output for 5.0.0 - 5.2.17
Serialized: a:2:{s:3:"foo";s:3:"bar";s:4:"user";O:8:"stdClass":3:{s:2:"id";i:1;s:4:"name";s:8:"John Doe";s:6:"hermit";O:6:"Herman":1:{s:12:"Hermanmilk";b:1;}}}array(2) { ["foo"]=> string(3) "bar" ["user"]=> object(stdClass)#3 (3) { ["id"]=> int(1) ["name"]=> string(8) "John Doe" ["hermit"]=> object(Herman)#4 (1) { ["milk:private"]=> bool(true) } } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/IrSkI on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/IrSkI on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/IrSkI on line 8
Process exited with code 255.