3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = 4; if($x == 1){ class X{} $x = []; $x["x"] = new X(); $x["y"] = "5"; echo serialize($x); // a:2:{s:1:"x";O:1:"X":0:{}s:1:"y";s:1:"5";} } elseif($x == 2){ $x = unserialize('a:2:{s:1:"x";O:1:"X":0:{}s:1:"y";s:1:"5";}'); print_r($x); /* Array ( [x] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => X ) [y] => 5 ) */ } elseif($x == 3){ enum Y{ case Y; } $x = []; $x["x"] = Y::Y; $x["y"] = "5"; echo serialize($x); // a:2:{s:1:"x";E:3:"Y:Y";s:1:"y";s:1:"5";} } elseif($x == 4){ $x = unserialize('a:2:{s:1:"x";E:3:"Y:Y";s:1:"y";s:1:"5";}'); print_r($x); }
Output for git.master_jit, git.master
Warning: unserialize(): Class 'Y' not found in /in/u130I on line 34 Warning: unserialize(): Error at offset 13 of 40 bytes in /in/u130I on line 34

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

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


preferences:
41.46 ms | 405 KiB | 5 Q