3v4l.org

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

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

End of function %00%7Bclosure%7D%2Fin%2FUXYTR%3A12%240

Class Foo:
Function add_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UXYTR
function name:  add_function
number of ops:  15
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
    5     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
    6     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
    7    10        INIT_FCALL                                               'var_dump'
         11        FETCH_THIS                                       ~5      
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                                 
    8    14      > RETURN                                                   null

End of function add_function

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.36 ms | 1396 KiB | 15 Q