3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestCache { protected $vars = array(); public function assign ($var, $value) { $this->vars[$var] = $value; } public function fetch ($var) { return $this->vars[$var]; } } $a = new stdClass; $a->x = 3; $cache = new TestCache(); $cache->assign('a', $a); $a->x = $a->x + 1; $cachedObject = $cache->fetch('a'); if ($cachedObject->x == $a->x) { print 'By reference'; } else { print 'By value'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u6b5G
function name:  (null)
number of ops:  28
compiled vars:  !0 = $a, !1 = $cache, !2 = $cachedObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   15     3        ASSIGN_OBJ                                               !0, 'x'
          4        OP_DATA                                                  3
   17     5        NEW                                              $7      'TestCache'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $7
   19     8        INIT_METHOD_CALL                                         !1, 'assign'
          9        SEND_VAL_EX                                              'a'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   21    12        FETCH_OBJ_R                                      ~12     !0, 'x'
         13        ADD                                              ~13     ~12, 1
         14        ASSIGN_OBJ                                               !0, 'x'
         15        OP_DATA                                                  ~13
   23    16        INIT_METHOD_CALL                                         !1, 'fetch'
         17        SEND_VAL_EX                                              'a'
         18        DO_FCALL                                      0  $14     
         19        ASSIGN                                                   !2, $14
   25    20        FETCH_OBJ_R                                      ~16     !2, 'x'
         21        FETCH_OBJ_R                                      ~17     !0, 'x'
         22        IS_EQUAL                                                 ~16, ~17
         23      > JMPZ                                                     ~18, ->26
   26    24    >   ECHO                                                     'By+reference'
         25      > JMP                                                      ->27
   28    26    >   ECHO                                                     'By+value'
   29    27    > > RETURN                                                   1

Class TestCache:
Function assign:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u6b5G
function name:  assign
number of ops:  6
compiled vars:  !0 = $var, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_OBJ_W                                      $2      'vars'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
    7     5      > RETURN                                                   null

End of function assign

Function fetch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u6b5G
function name:  fetch
number of ops:  5
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        FETCH_OBJ_R                                      ~1      'vars'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   11     4*     > RETURN                                                   null

End of function fetch

End of class TestCache.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.29 ms | 1399 KiB | 13 Q