3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { function RunEvent($event) { if (isset($this->events[$event])) { foreach ($this->events[$event] as $k => $v) { //call_user_func($v, &$this); // The above line is working code on PHP 5.3.3, but // throws a parse error on PHP 5.5.3. call_user_func($v, $this); } } } } $e = new Example; $e->events['example'][] = 'with_ref'; $e->events['example'][] = 'without_ref'; $e->RunEvent('example'); function with_ref(Example $e) { $e->with_ref = true; } function without_ref(Example $e) { $e->without_ref = true; } print_r($e);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gurGu
function name:  (null)
number of ops:  18
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $1      'Example'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   18     3        FETCH_OBJ_W                                      $4      !0, 'events'
          4        FETCH_DIM_W                                      $5      $4, 'example'
          5        ASSIGN_DIM                                               $5
          6        OP_DATA                                                  'with_ref'
   19     7        FETCH_OBJ_W                                      $7      !0, 'events'
          8        FETCH_DIM_W                                      $8      $7, 'example'
          9        ASSIGN_DIM                                               $8
         10        OP_DATA                                                  'without_ref'
   20    11        INIT_METHOD_CALL                                         !0, 'RunEvent'
         12        SEND_VAL_EX                                              'example'
         13        DO_FCALL                                      0          
   28    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function with_ref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gurGu
function name:  with_ref
number of ops:  4
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        ASSIGN_OBJ                                               !0, 'with_ref'
          2        OP_DATA                                                  <true>
   23     3      > RETURN                                                   null

End of function with_ref

Function without_ref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gurGu
function name:  without_ref
number of ops:  4
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        ASSIGN_OBJ                                               !0, 'without_ref'
          2        OP_DATA                                                  <true>
   26     3      > RETURN                                                   null

End of function without_ref

Class Example:
Function runevent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 15
filename:       /in/gurGu
function name:  RunEvent
number of ops:  16
compiled vars:  !0 = $event, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        FETCH_OBJ_IS                                     ~3      'events'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, !0
          3      > JMPZ                                                     ~4, ->15
    6     4    >   FETCH_OBJ_R                                      ~5      'events'
          5        FETCH_DIM_R                                      ~6      ~5, !0
          6      > FE_RESET_R                                       $7      ~6, ->14
          7    > > FE_FETCH_R                                       ~8      $7, !1, ->14
          8    >   ASSIGN                                                   !2, ~8
   10     9        INIT_USER_CALL                                1          'call_user_func', !1
         10        FETCH_THIS                                       ~10     
         11        SEND_USER                                                ~10
         12        DO_FCALL                                      0          
    6    13      > JMP                                                      ->7
         14    >   FE_FREE                                                  $7
   13    15    > > RETURN                                                   null

End of function runevent

End of class Example.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.1 ms | 1400 KiB | 15 Q