3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function add_function($name, $function) { $this->$name = $function; } function call($name) { call_user_func($this->$name); } } $foo = new Foo(); $foo->add_function('bar', function() { echo "hello, world"; }); $foo->call('bar');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IEGEQ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   13     3        INIT_METHOD_CALL                                         !0, 'add_function'
          4        SEND_VAL_EX                                              'bar'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIEGEQ%3A13%240'
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0          
   14     8        INIT_METHOD_CALL                                         !0, 'call'
          9        SEND_VAL_EX                                              'bar'
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FIEGEQ%3A13%240

Class Foo:
Function add_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IEGEQ
function name:  add_function
number of ops:  5
compiled vars:  !0 = $name, !1 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
    6     4      > RETURN                                                   null

End of function add_function

Function call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IEGEQ
function name:  call
number of ops:  5
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        FETCH_OBJ_R                                      ~1      !0
          2        INIT_USER_CALL                                0          'call_user_func', ~1
          3        DO_FCALL                                      0          
    9     4      > RETURN                                                   null

End of function call

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.11 ms | 1395 KiB | 13 Q