3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { public $a = true; public function __sleep() { return array('a', '1'); } } $a = new C; $s = serialize($a); var_dump($s); var_dump(unserialize($s));
based on 81nem
Output for 8.0.0
Warning: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/Fprda on line 13 string(24) "O:1:"C":1:{s:1:"a";b:1;}" object(C)#2 (1) { ["a"]=> bool(true) }
Output for 5.0.2 - 5.0.4, 5.1.0 - 5.1.6, 5.2.0 - 5.2.5, 5.3.9 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.24, 7.4.0 - 7.4.13
Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/Fprda on line 13 string(34) "O:1:"C":2:{s:1:"a";b:1;s:1:"1";N;}" object(C)#2 (2) { ["a"]=> bool(true) ["1"]=> NULL }
Output for 5.2.6 - 5.2.17, 5.3.0 - 5.3.8
Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/Fprda on line 13 string(34) "O:1:"C":2:{s:1:"a";b:1;s:1:"1";N;}" object(C)#2 (2) { ["a"]=> bool(true) [1]=> NULL }
Output for 5.0.5

Process exited with code 139.
Output for 5.0.0 - 5.0.1
string(34) "O:1:"C":2:{s:1:"a";b:1;s:1:"1";N;}" object(C)#2 (2) { ["a"]=> bool(true) ["1"]=> NULL }
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/Fprda on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Fprda on line 4
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/Fprda on line 4
Process exited with code 255.