3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addition($num1){ return function ($num2) use ($num1){ return $num1*$num2; }; } $add_2_to = addition(2); echo $add_2_to(3); echo $add_2_to(4); echo (addition(2))(3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Fcte
function name:  (null)
number of ops:  20
compiled vars:  !0 = $add_2_to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'addition'
          1        SEND_VAL                                                 2
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
    9     4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAL_EX                                              3
          6        DO_FCALL                                      0  $3      
          7        ECHO                                                     $3
   10     8        INIT_DYNAMIC_CALL                                        !0
          9        SEND_VAL_EX                                              4
         10        DO_FCALL                                      0  $4      
         11        ECHO                                                     $4
   12    12        INIT_FCALL                                               'addition'
         13        SEND_VAL                                                 2
         14        DO_FCALL                                      0  $5      
         15        INIT_DYNAMIC_CALL                                        $5
         16        SEND_VAL_EX                                              3
         17        DO_FCALL                                      0  $6      
         18        ECHO                                                     $6
         19      > RETURN                                                   1

Function addition:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Fcte
function name:  addition
number of ops:  5
compiled vars:  !0 = $num1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F4Fcte%3A4%240'
          2        BIND_LEXICAL                                             ~1, !0
    6     3      > RETURN                                                   ~1
    7     4*     > RETURN                                                   null

End of function addition

Function %00%7Bclosure%7D%2Fin%2F4Fcte%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Fcte
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $num2, !1 = $num1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    5     2        MUL                                              ~2      !1, !0
          3      > RETURN                                                   ~2
    6     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F4Fcte%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.93 ms | 1399 KiB | 15 Q