3v4l.org

run code in 300+ PHP versions simultaneously
<?php function event($n, $h = null) { static $e = []; return $h ? $e[$n][] = $h : (isset($e[$n]) ? array_walk($e[$n], function($e) {$e();}) : 0); } event('hello', function () { echo 'hello!'; }); echo event('hello') ? 'true!' : 'false!'; echo event('world') ? 'true!' : 'false!';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
Branch analysis from position: 19
filename:       /in/9YACf
function name:  (null)
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'event'
          1        SEND_VAL                                                 'hello'
          2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9YACf%3A4%241'
          3        SEND_VAL                                                 ~0
          4        DO_FCALL                                      0          
    6     5        INIT_FCALL                                               'event'
          6        SEND_VAL                                                 'hello'
          7        DO_FCALL                                      0  $2      
          8      > JMPZ                                                     $2, ->11
          9    >   QM_ASSIGN                                        ~3      'true%21'
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~3      'false%21'
         12    >   ECHO                                                     ~3
    7    13        INIT_FCALL                                               'event'
         14        SEND_VAL                                                 'world'
         15        DO_FCALL                                      0  $4      
         16      > JMPZ                                                     $4, ->19
         17    >   QM_ASSIGN                                        ~5      'true%21'
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~5      'false%21'
         20    >   ECHO                                                     ~5
         21      > RETURN                                                   1

Function event:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9YACf
function name:  event
number of ops:  23
compiled vars:  !0 = $n, !1 = $h, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        BIND_STATIC                                              !2
          3      > JMPZ                                                     !1, ->9
          4    >   FETCH_DIM_W                                      $3      !2, !0
          5        ASSIGN_DIM                                       ~4      $3
          6        OP_DATA                                                  !1
          7        QM_ASSIGN                                        ~5      ~4
          8      > JMP                                                      ->21
          9    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, !0
         10      > JMPZ                                                     ~6, ->19
         11    >   INIT_FCALL                                               'array_walk'
         12        FETCH_DIM_W                                      $7      !2, !0
         13        SEND_REF                                                 $7
         14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9YACf%3A2%240'
         15        SEND_VAL                                                 ~8
         16        DO_ICALL                                         $9      
         17        QM_ASSIGN                                        ~10     $9
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~10     0
         20    >   QM_ASSIGN                                        ~5      ~10
         21    > > RETURN                                                   ~5
         22*     > RETURN                                                   null

End of function event

Function %00%7Bclosure%7D%2Fin%2F9YACf%3A2%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9YACf
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0          
          3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9YACf%3A2%240

Function %00%7Bclosure%7D%2Fin%2F9YACf%3A4%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9YACf
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ECHO                                                     'hello%21'
          1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9YACf%3A4%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
192.38 ms | 1394 KiB | 18 Q