3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function memoize($func) { return function () use ($func) { static $cache = []; $args = func_get_args(); $key = md5(serialize($args)); if ( !isset($cache[$key]) ) { $cache[$key] = call_user_func_array($func, $args); } return $cache[$key]; }; }; $cube = function($number) { return $number * $number * $number; }; $cube3 = memoize($cube, 3); echo $cube3();
based on BpXS8
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 0 passed in /in/QXTZP on line 10 and exactly 1 expected in /in/QXTZP:18 Stack trace: #0 /in/QXTZP(10): {closure}() #1 /in/QXTZP(24): {closure}() #2 {main} thrown in /in/QXTZP on line 18
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Missing argument 1 for {closure}(), called in /in/QXTZP on line 10 and defined in /in/QXTZP on line 18 Notice: Undefined variable: number in /in/QXTZP on line 19 Notice: Undefined variable: number in /in/QXTZP on line 19 Notice: Undefined variable: number in /in/QXTZP on line 19 0
Output for 5.4.0 - 5.6.28
Warning: Missing argument 1 for {closure}() in /in/QXTZP on line 18 Notice: Undefined variable: number in /in/QXTZP on line 19 Notice: Undefined variable: number in /in/QXTZP on line 19 Notice: Undefined variable: number in /in/QXTZP on line 19 0
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/QXTZP on line 4
Process exited with code 255.