3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function create_function2($args, $content) { static $counter = 0; $funcname = "\0lambda_" . (++$counter); eval("function $funcname ({$args}) { {$content}; }"); return $funcname; } $func1 = create_function('$a,$b', 'return $a.$b;'); $func2 = create_function2('$a,$b', 'return $a.$b;'); $rs1 = $func1(1, 2); $rs2 = $func2(1, 2); var_dump($func1, $rs1); var_dump($func2, $rs2); var_dump(function_exists($func1), function_exists($func2));
Output for 4.3.0 - 7.1.0
Warning: Unexpected character in input: ' in /in/UL7Vc(6) : eval()'d code on line 1 string(9) "lambda_1" string(2) "12" string(9) "lambda_1" string(2) "12" bool(true) bool(true)