3v4l.org

run code in 500+ PHP versions simultaneously
<?php $log = []; $appendToLogFx = static fn () => $log[] = 'foo'; $appendToLogFx(); var_dump($log); $appendToLogFx = static function () use (&$log) { $log[] = 'foo'; }; $appendToLogFx(); var_dump($log);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aP6T0
function name:  (null)
number of ops:  18
compiled vars:  !0 = $log, !1 = $appendToLogFx
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          2        BIND_LEXICAL                                                 ~3, !0
          3        ASSIGN                                                       !1, ~3
    6     4        INIT_DYNAMIC_CALL                                            !1
          5        DO_FCALL                                          0          
    7     6        INIT_FCALL                                                   'var_dump'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                                     
    9     9        DECLARE_LAMBDA_FUNCTION                              ~7      [1]
         10        BIND_LEXICAL                                                 ~7, !0
         11        ASSIGN                                                       !1, ~7
   13    12        INIT_DYNAMIC_CALL                                            !1
         13        DO_FCALL                                          0          
   14    14        INIT_FCALL                                                   'var_dump'
         15        SEND_VAR                                                     !0
         16        DO_ICALL                                                     
         17      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aP6T0
function name:  {closure:/in/aP6T0:4}
number of ops:  5
compiled vars:  !0 = $log
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   BIND_STATIC                                                  !0
          1        ASSIGN_DIM                                           ~1      !0
          2        OP_DATA                                                      'foo'
          3      > RETURN                                                       ~1
          4*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aP6T0
function name:  {closure:/in/aP6T0:9}
number of ops:  4
compiled vars:  !0 = $log
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   BIND_STATIC                                                  !0
   10     1        ASSIGN_DIM                                                   !0
          2        OP_DATA                                                      'foo'
   11     3      > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
144.42 ms | 487 KiB | 10 Q