3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 S8lRA
Output for 5.6.8 - 7.3.1
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/81nem on line 13 Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/81nem 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.3 - 5.0.4, 5.1.0 - 5.2.4, 5.3.0 - 5.5.35
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/81nem on line 13 string(26) "O:1:"C":2:{s:1:"a";b:1;N;}" Notice: unserialize(): Error at offset 25 of 26 bytes in /in/81nem on line 15 bool(false)
Output for 5.2.5 - 5.2.17
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize in /in/81nem on line 13 string(26) "O:1:"C":2:{s:1:"a";b:1;N;}" Notice: unserialize(): Error at offset 25 of 26 bytes in /in/81nem on line 15 bool(false)
Output for 5.0.5

Process exited with code 139.
Output for 5.0.0 - 5.0.2
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/81nem on line 13 string(26) "O:1:"C":2:{s:1:"a";b:1;N;}" Notice: unserialize(): Unexpected end of serialized data in /in/81nem on line 15 Notice: unserialize(): Error at offset 25 of 26 bytes in /in/81nem on line 15 bool(false)
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/81nem on line 4
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/81nem 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/81nem on line 4
Process exited with code 255.