3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function closure() { $a = 0; return function () use (&$a) { return $a++; }; } $c = closure(); var_dump($c()); var_dump($c()); var_dump($c()); var_dump($c()); var_dump($c()); var_dump(function () { return $c; });
based on bPeX5
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
int(0) int(1) int(2) int(3) int(4) object(Closure)#2 (0) { }
Output for hhvm-3.15.4
int(0) int(1) int(2) int(3) int(4) object(Closure$closure#2;290874998$980d63ba1b1ece9bf1367ddac369d788$)#2 (0) { }