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 {$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));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Osb9T
function name:  (null)
number of ops:  29
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'var_dump'
   11     1        INIT_FCALL_BY_NAME                                       'create_function'
          2        SEND_VAL_EX                                              '%24a%2C%24b'
          3        SEND_VAL_EX                                              'return+%24a%2B%24b%3B'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
   12     6        INIT_FCALL                                               'bin2hex'
          7        INIT_FCALL_BY_NAME                                       'create_function'
          8        SEND_VAL_EX                                              '%24a%2C%24b'
          9        SEND_VAL_EX                                              'return+%24a%2B%24b%3B'
         10        DO_FCALL                                      0  $2      
         11        SEND_VAR                                                 $2
         12        DO_ICALL                                         $3      
         13        SEND_VAR                                                 $3
         14        DO_ICALL                                                 
   15    15        INIT_FCALL                                               'create_function2'
         16        SEND_VAL                                                 '%24a%2C%24b'
         17        SEND_VAL                                                 'return+%24a%2B%24b%3B'
         18        DO_FCALL                                      0  $5      
         19        ASSIGN                                                   !0, $5
   16    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !0
         22        INIT_DYNAMIC_CALL                                        !0
         23        SEND_VAL_EX                                              1
         24        SEND_VAL_EX                                              2
         25        DO_FCALL                                      0  $7      
         26        SEND_VAR                                                 $7
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function create_function2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Osb9T
function name:  create_function2
number of ops:  16
compiled vars:  !0 = $args, !1 = $content, !2 = $counter, !3 = $funcname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        BIND_STATIC                                              !2
    5     3        PRE_DEC                                          ~4      !2
          4        CONCAT                                           ~5      '_lambda_', ~4
          5        ASSIGN                                                   !3, ~5
    6     6        ROPE_INIT                                     7  ~8      'function+'
          7        ROPE_ADD                                      1  ~8      ~8, !3
          8        ROPE_ADD                                      2  ~8      ~8, '+%28'
          9        ROPE_ADD                                      3  ~8      ~8, !0
         10        ROPE_ADD                                      4  ~8      ~8, '%29+%7B+'
         11        ROPE_ADD                                      5  ~8      ~8, !1
         12        ROPE_END                                      6  ~7      ~8, '%3B+%7D'
         13        INCLUDE_OR_EVAL                                          ~7, EVAL
    7    14      > RETURN                                                   !3
    8    15*     > RETURN                                                   null

End of function create_function2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.38 ms | 1403 KiB | 18 Q