3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ 'test' => 1 ]; $b = serialize($a); var_dump(unserialize($b)); echo"<br />"; echo"<br />"; var_dump("---------------"); echo"<br />"; echo"<br />"; var_dump(unserialize($b, ['allowed_classes'=>['stdClass']])); echo"<br />"; echo"<br />"; var_dump("---------------"); var_dump(count(unserialize($b, ['allowed_classes'=>false]))); echo"<br />"; echo"<br />"; var_dump("---------------"); var_dump(unserialize($b, false)); echo"<br />"; echo"<br />"; var_dump("---------------"); var_dump(unserialize($b, ['allowed_classes'=>true])); echo"<br />"; echo"<br />"; var_dump("---------------"); var_dump(unserialize($b, [false]));
based on oId9j
Output for 7.3.0alpha1 - 7.3.0rc3
array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" <br /><br />array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" int(1) <br /><br />string(15) "---------------" Warning: unserialize() expects parameter 2 to be array, bool given in /in/df1nW on line 24 bool(false) <br /><br />string(15) "---------------" array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" array(1) { ["test"]=> int(1) }
Output for 7.0.0 - 7.2.11
array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" <br /><br />array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" int(1) <br /><br />string(15) "---------------" Warning: unserialize() expects parameter 2 to be array, boolean given in /in/df1nW on line 24 bool(false) <br /><br />string(15) "---------------" array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" array(1) { ["test"]=> int(1) }
Output for hhvm-3.15.4
array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" <br /><br />array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" int(1) <br /><br />string(15) "---------------" Warning: unserialize() expects parameter 2 to be array, boolean given in /in/df1nW on line 24 NULL <br /><br />string(15) "---------------" array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" array(1) { ["test"]=> int(1) }
Output for 5.6.0 - 5.6.30
array(1) { ["test"]=> int(1) } <br /><br />string(15) "---------------" <br /><br /> Warning: unserialize() expects exactly 1 parameter, 2 given in /in/df1nW on line 16 bool(false) <br /><br />string(15) "---------------" Warning: unserialize() expects exactly 1 parameter, 2 given in /in/df1nW on line 20 int(1) <br /><br />string(15) "---------------" Warning: unserialize() expects exactly 1 parameter, 2 given in /in/df1nW on line 24 bool(false) <br /><br />string(15) "---------------" Warning: unserialize() expects exactly 1 parameter, 2 given in /in/df1nW on line 29 bool(false) <br /><br />string(15) "---------------" Warning: unserialize() expects exactly 1 parameter, 2 given in /in/df1nW on line 34 bool(false)