3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class foo { public $throw_exception = false; function __sleep() { return array('throw_exception' => true); } function __construct() { echo "construct called\n"; if ($this->throw_exception == true) { throw new Exception(); } } } $a = new foo; $x = serialize($a); $y = unserialize($x);
Output for 5.6.8 - 5.6.28, 7.0.0 - 7.1.0
construct called Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/HTOEc on line 17 Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/HTOEc on line 17
Output for hhvm-3.10.0 - 3.12.0
construct called Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/HTOEc on line 17
Output for 5.0.3 - 5.0.4, 5.1.0 - 5.2.4, 5.3.0 - 5.6.7
construct called Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/HTOEc on line 17 Notice: unserialize(): Error at offset 15 of 16 bytes in /in/HTOEc on line 18
Output for 5.2.5 - 5.2.17
construct called Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize in /in/HTOEc on line 17 Notice: unserialize(): Error at offset 15 of 16 bytes in /in/HTOEc on line 18
Output for 5.0.5
construct called
Process exited with code 139.
Output for 5.0.0 - 5.0.2
construct called Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/HTOEc on line 17 Notice: unserialize(): Unexpected end of serialized data in /in/HTOEc on line 18 Notice: unserialize(): Error at offset 15 of 16 bytes in /in/HTOEc on line 18
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/HTOEc 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/HTOEc 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/HTOEc on line 4
Process exited with code 255.