3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { protected $_a = 6; function __get($key) { if($key == 'stuff') { return $this->stuff(); } else if($key == 'a') { return $this->_a; } } function stuff() { return array('random' => 'key', 'using_getter' => 10 * $this->a); } } $test = new test(); print 'this should be 60: '.$test->stuff['using_getter'].PHP_EOL; print 'this should be 6: '.$test->a.PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YZHgS
function name:  (null)
number of ops:  13
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   22     3        FETCH_OBJ_R                                      ~4      !0, 'stuff'
          4        FETCH_DIM_R                                      ~5      ~4, 'using_getter'
          5        CONCAT                                           ~6      'this+should+be+60%3A+', ~5
          6        CONCAT                                           ~7      ~6, '%0A'
          7        ECHO                                                     ~7
   23     8        FETCH_OBJ_R                                      ~8      !0, 'a'
          9        CONCAT                                           ~9      'this+should+be+6%3A+', ~8
         10        CONCAT                                           ~10     ~9, '%0A'
         11        ECHO                                                     ~10
         12      > RETURN                                                   1

Class test:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YZHgS
function name:  __get
number of ops:  12
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        IS_EQUAL                                                 !0, 'stuff'
          2      > JMPZ                                                     ~1, ->7
    9     3    >   INIT_METHOD_CALL                                         'stuff'
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
          6*       JMP                                                      ->11
   10     7    >   IS_EQUAL                                                 !0, 'a'
          8      > JMPZ                                                     ~3, ->11
   11     9    >   FETCH_OBJ_R                                      ~4      '_a'
         10      > RETURN                                                   ~4
   13    11    > > RETURN                                                   null

End of function __get

Function stuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YZHgS
function name:  stuff
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_ARRAY                                       ~0      'key', 'random'
          1        FETCH_OBJ_R                                      ~1      'a'
          2        MUL                                              ~2      ~1, 10
          3        ADD_ARRAY_ELEMENT                                ~0      ~2, 'using_getter'
          4      > RETURN                                                   ~0
   18     5*     > RETURN                                                   null

End of function stuff

End of class test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.24 ms | 1399 KiB | 13 Q