3v4l.org

run code in 300+ PHP versions simultaneously
<?php $globalFunction = function($var){ echo "works $var"; }; class TestClass{ private $globalFunction; function __construct(){ $this->globalFunction = $GLOBALS['globalFunction']; } function testFunc(){ ($this->globalFunction)('a'); } } $arr = new TestClass(); $arr->testFunc();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9X7uq
function name:  (null)
number of ops:  8
compiled vars:  !0 = $globalFunction, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          1        ASSIGN                                                   !0, ~2
   16     2        NEW                                              $4      'TestClass'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   17     5        INIT_METHOD_CALL                                         !1, 'testFunc'
          6        DO_FCALL                                      0          
          7      > 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/9X7uq
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'works+', !0
          3        ECHO                                                     ~1
    5     4      > RETURN                                                   null

End of Dynamic Function 0

Class TestClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9X7uq
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_R                      global              ~1      'globalFunction'
          1        ASSIGN_OBJ                                               'globalFunction'
          2        OP_DATA                                                  ~1
   11     3      > RETURN                                                   null

End of function __construct

Function testfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9X7uq
function name:  testFunc
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_R                                      ~0      'globalFunction'
          1        INIT_DYNAMIC_CALL                                        ~0
          2        SEND_VAL_EX                                              'a'
          3        DO_FCALL                                      0          
   14     4      > RETURN                                                   null

End of function testfunc

End of class TestClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.35 ms | 1000 KiB | 13 Q