3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { function __construct() { $this->a = "hello"; $this->b = "hi"; $this->val = "howdy"; $val = "a"; echo $this->{$val}; // outputs "hello" echo "\n"; $val = "b"; echo $this->{$val}; // outputs "hi" echo "\n"; echo $this->val; //outputs "howdy" echo "\n"; echo $this->{"val"}; } function __construct2() { echo $this->{$val}; // outputs "hello" } } $foo = new foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fARrp
function name:  (null)
number of ops:  4
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $1      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
          3      > RETURN                                                   1

Class foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fARrp
function name:  __construct
number of ops:  20
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN_OBJ                                               'a'
          1        OP_DATA                                                  'hello'
    6     2        ASSIGN_OBJ                                               'b'
          3        OP_DATA                                                  'hi'
    7     4        ASSIGN_OBJ                                               'val'
          5        OP_DATA                                                  'howdy'
    9     6        ASSIGN                                                   !0, 'a'
   10     7        FETCH_OBJ_R                                      ~5      !0
          8        ECHO                                                     ~5
   12     9        ECHO                                                     '%0A'
   14    10        ASSIGN                                                   !0, 'b'
   15    11        FETCH_OBJ_R                                      ~7      !0
         12        ECHO                                                     ~7
   17    13        ECHO                                                     '%0A'
   18    14        FETCH_OBJ_R                                      ~8      'val'
         15        ECHO                                                     ~8
   20    16        ECHO                                                     '%0A'
   21    17        FETCH_OBJ_R                                      ~9      'val'
         18        ECHO                                                     ~9
   22    19      > RETURN                                                   null

End of function __construct

Function __construct2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fARrp
function name:  __construct2
number of ops:  3
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~1      !0
          1        ECHO                                                     ~1
   26     2      > RETURN                                                   null

End of function __construct2

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.54 ms | 1386 KiB | 13 Q