3v4l.org

run code in 300+ PHP versions simultaneously
<?php function myClosure( $num ) { return function( $x ) use( $num ){ return $num - $x; }; } $closure = myClosure( 10 ); echo $closure( 2 )."\n"; echo $closure( 3 )."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6aOKL
function name:  (null)
number of ops:  15
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'myclosure'
          1        SEND_VAL                                                 10
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
    9     4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0  $3      
          7        CONCAT                                           ~4      $3, '%0A'
          8        ECHO                                                     ~4
   10     9        INIT_DYNAMIC_CALL                                        !0
         10        SEND_VAL_EX                                              3
         11        DO_FCALL                                      0  $5      
         12        CONCAT                                           ~6      $5, '%0A'
         13        ECHO                                                     ~6
         14      > RETURN                                                   1

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

End of function myclosure

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

End of function %00%7Bclosure%7D%2Fin%2F6aOKL%3A3%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.59 ms | 1399 KiB | 14 Q