3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $func = function () { static $val; if (!isset($val)) { $val = 0; } return ++$val; }; var_dump($func()); $func2 = clone $func; var_dump($func()); var_dump($func2());
Output for 5.4.0 - 5.6.38, 7.1.0 - 7.3.0
int(1) int(2) int(2)
Output for 7.0.0 - 7.0.33
int(1) int(2) int(3)
Output for 5.3.0 - 5.3.29
int(1) Fatal error: Trying to clone an uncloneable object of class Closure in /in/B5AZ3 on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/B5AZ3 on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/B5AZ3 on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/B5AZ3 on line 2
Process exited with code 255.