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));
Output for 5.2.3 - 5.6.28, 7.0.0 - 7.1.0
Warning: Unexpected character in input: ' in /in/XRICB(6) : eval()'d code on line 1 string(9) "lambda_1" string(2) "12" string(9) "lambda_1" string(2) "12" bool(true)
Output for hhvm-3.10.0 - 3.12.0
string(9) "lambda_1" string(2) "12" string(9) "lambda_1" string(2) "12" bool(true)
Output for 4.3.0 - 5.2.2
<br /> <b>Warning</b>: Unexpected character in input: ' in <b>/in/XRICB(6) : eval()'d code</b> on line <b>1</b><br /> string(9) "lambda_1" string(2) "12" string(9) "lambda_1" string(2) "12" bool(true)