3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function create_function2($args, $content) { static $counter = PHP_MAX_INT; $funcname = '_lambda_' . (--$counter); eval("function {$funcname} ({$args}) { {$content}; }"); return $funcname; } var_dump( create_function('$a,$b', 'return $a+$b;'), bin2hex(create_function('$a,$b', 'return $a+$b;')) ); $f = create_function2('$a,$b', 'return $a+$b;'); var_dump($f, $f(1,2));
Output for 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(9) "lambda_1" string(18) "006c616d6264615f32" Notice: Use of undefined constant PHP_MAX_INT - assumed 'PHP_MAX_INT' in /in/8jYXW on line 4 string(19) "_lambda_PHP_MAX_INT" int(3)
Output for 4.3.0 - 5.4.45
string(9) "lambda_1" string(18) "006c616d6264615f32" string(19) "_lambda_PHP_MAX_INT" int(3)