3v4l.org

run code in 300+ PHP versions simultaneously
<?php function create_function2($args, $content) { static $counter = PHP_INT_MAX; $funcname = 'lambda_' . (--$counter); eval("function \0{$funcname} ({$args}) { {$content}; }"); return $funcname; } $funcname = 'test'; function $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.5.5
Parse error: syntax error, unexpected '$funcname' (T_VARIABLE), expecting '(' in /in/GO7do on line 11
Process exited with code 255.
Output for 5.4.0 - 5.4.21
Parse error: syntax error, unexpected '$funcname' (T_VARIABLE), expecting identifier (T_STRING) or '(' in /in/GO7do on line 11
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING or '(' in /in/GO7do on line 11
Process exited with code 255.

preferences:
180.49 ms | 1395 KiB | 63 Q