3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function closure() { $a = 0; return function ($a) { return $a++; }; } $c = closure(); var_dump($c()); var_dump($c()); var_dump($c()); var_dump($c()); var_dump($c());
based on 2Cvmu
Output for 7.1.0 - 7.3.0rc3
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 0 passed in /in/t4qVe on line 11 and exactly 1 expected in /in/t4qVe:5 Stack trace: #0 /in/t4qVe(11): {closure}() #1 {main} thrown in /in/t4qVe on line 5
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
Warning: Missing argument 1 for {closure}(), called in /in/t4qVe on line 11 and defined in /in/t4qVe on line 5 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: Missing argument 1 for {closure}(), called in /in/t4qVe on line 12 and defined in /in/t4qVe on line 5 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: Missing argument 1 for {closure}(), called in /in/t4qVe on line 13 and defined in /in/t4qVe on line 5 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: Missing argument 1 for {closure}(), called in /in/t4qVe on line 14 and defined in /in/t4qVe on line 5 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: Missing argument 1 for {closure}(), called in /in/t4qVe on line 15 and defined in /in/t4qVe on line 5 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL
Output for hhvm-3.15.4
Warning: __invoke() expects exactly 1 parameter, 0 given in /in/t4qVe on line 6 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: __invoke() expects exactly 1 parameter, 0 given in /in/t4qVe on line 6 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: __invoke() expects exactly 1 parameter, 0 given in /in/t4qVe on line 6 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: __invoke() expects exactly 1 parameter, 0 given in /in/t4qVe on line 6 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL Warning: __invoke() expects exactly 1 parameter, 0 given in /in/t4qVe on line 6 Notice: Undefined variable: a in /in/t4qVe on line 6 NULL