3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function create_function2($args, $content) { static $counter = 0; $funcname = "lambda_" . (++$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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A2Lvd
function name:  (null)
number of ops:  30
compiled vars:  !0 = $func1, !1 = $func2, !2 = $rs1, !3 = $rs2
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  10     1        INIT_FCALL                                               'create_function'
         2        SEND_VAL                                                 '%24a%2C%24b'
         3        SEND_VAL                                                 'return+%24a.%24b%3B'
         4        DO_FCALL_BY_NAME                                         
         5        ASSIGN                                                   !0, $4
  11     6        INIT_FCALL                                               'create_function2'
         7        SEND_VAL                                                 '%24a%2C%24b'
         8        SEND_VAL                                                 'return+%24a.%24b%3B'
         9        DO_FCALL                                      0  $6      
        10        ASSIGN                                                   !1, $6
  13    11        INIT_DYNAMIC_CALL                                        !0
        12        SEND_VAL_EX                                              1
        13        SEND_VAL_EX                                              2
        14        DO_FCALL                                      0  $8      
        15        ASSIGN                                                   !2, $8
  14    16        INIT_DYNAMIC_CALL                                        !1
        17        SEND_VAL_EX                                              1
        18        SEND_VAL_EX                                              2
        19        DO_FCALL                                      0  $10     
        20        ASSIGN                                                   !3, $10
  16    21        INIT_FCALL                                               'var_dump'
        22        SEND_VAR                                                 !0
        23        SEND_VAR                                                 !2
        24        DO_ICALL                                                 
  17    25        INIT_FCALL                                               'var_dump'
        26        SEND_VAR                                                 !1
        27        SEND_VAR                                                 !3
        28        DO_ICALL                                                 
        29      > RETURN                                                   1

Function create_function2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A2Lvd
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, 'counter'
   5     3        PRE_INC                                          $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 7.3.0