3v4l.org

run code in 300+ PHP versions simultaneously
<?php class cls{ public $data; public $active; function __construct(){ $this->data = '<li class="'.$this->active.'"></li>'; } function test(){ $this->active = 'active'; return $this->active; } } $cls = new cls; echo $cls->data; // Why __construct() does not update ?
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UqcRf
function name:  (null)
number of ops:  6
compiled vars:  !0 = $cls
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $1      'cls'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   18     3        FETCH_OBJ_R                                      ~4      !0, 'data'
          4        ECHO                                                     ~4
          5      > RETURN                                                   1

Class cls:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UqcRf
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~1      'active'
          1        CONCAT                                           ~2      '%3Cli+class%3D%22', ~1
          2        CONCAT                                           ~3      ~2, '%22%3E%3C%2Fli%3E'
          3        ASSIGN_OBJ                                               'data'
          4        OP_DATA                                                  ~3
    9     5      > RETURN                                                   null

End of function __construct

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UqcRf
function name:  test
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN_OBJ                                               'active'
          1        OP_DATA                                                  'active'
   13     2        FETCH_OBJ_R                                      ~1      'active'
          3      > RETURN                                                   ~1
   14     4*     > RETURN                                                   null

End of function test

End of class cls.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.61 ms | 995 KiB | 13 Q