3v4l.org

run code in 300+ PHP versions simultaneously
<?php class InCommon { private $baz = 'foo'; public function out($pref){ echo "\n".$pref.'::$baz = '.$this->baz; } } class Foo extends InCommon { public function peek($target, $pref){ echo "\n".'peek @'.$pref.'::$baz = '.$target->baz; } } class Bar extends InCommon { public function peek($target, $pref){ echo "\n".'peek @'.$pref.'::$baz = '.$target->baz; } public function mess($target){ $target->baz = 'cats'; } } $foo = new Foo(); $bar = new Bar(); echo "Messing with variable"; $bar->mess($foo); // bar messes with foo's baz, which should be private echo "\nFoo looks at its own $baz:"; $foo->out('Foo'); // foo looks at its own baz, which remains unchanged echo "\nBar looks at Foo's $baz:"; $bar->peek($foo, 'Foo'); // yet when bar looks at foo's baz (which is shouldn't see) we get the change from above echo "\n\nFoo can't look at Bar's $baz"; $foo->peek($bar, 'Bar');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  (null)
number of ops:  33
compiled vars:  !0 = $foo, !1 = $bar, !2 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   21     3        NEW                                              $6      'Bar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   23     6        ECHO                                                     'Messing+with+variable'
   24     7        INIT_METHOD_CALL                                         !1, 'mess'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   26    10        ROPE_INIT                                     3  ~11     '%0AFoo+looks+at+its+own+'
         11        ROPE_ADD                                      1  ~11     ~11, !2
         12        ROPE_END                                      2  ~10     ~11, '%3A'
         13        ECHO                                                     ~10
   27    14        INIT_METHOD_CALL                                         !0, 'out'
         15        SEND_VAL_EX                                              'Foo'
         16        DO_FCALL                                      0          
   28    17        ROPE_INIT                                     3  ~15     '%0ABar+looks+at+Foo%27s+'
         18        ROPE_ADD                                      1  ~15     ~15, !2
         19        ROPE_END                                      2  ~14     ~15, '%3A'
         20        ECHO                                                     ~14
   29    21        INIT_METHOD_CALL                                         !1, 'peek'
         22        SEND_VAR_EX                                              !0
         23        SEND_VAL_EX                                              'Foo'
         24        DO_FCALL                                      0          
   31    25        NOP                                                      
         26        FAST_CONCAT                                      ~18     '%0A%0AFoo+can%27t+look+at+Bar%27s+', !2
         27        ECHO                                                     ~18
   32    28        INIT_METHOD_CALL                                         !0, 'peek'
         29        SEND_VAR_EX                                              !1
         30        SEND_VAL_EX                                              'Bar'
         31        DO_FCALL                                      0          
         32      > RETURN                                                   1

Class InCommon:
Function out:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  out
number of ops:  7
compiled vars:  !0 = $pref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        CONCAT                                           ~1      '%0A', !0
          2        CONCAT                                           ~2      ~1, '%3A%3A%24baz+%3D+'
          3        FETCH_OBJ_R                                      ~3      'baz'
          4        CONCAT                                           ~4      ~2, ~3
          5        ECHO                                                     ~4
    6     6      > RETURN                                                   null

End of function out

End of class InCommon.

Class Foo:
Function peek:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  peek
number of ops:  8
compiled vars:  !0 = $target, !1 = $pref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        CONCAT                                           ~2      '%0Apeek+%40', !1
          3        CONCAT                                           ~3      ~2, '%3A%3A%24baz+%3D+'
          4        FETCH_OBJ_R                                      ~4      !0, 'baz'
          5        CONCAT                                           ~5      ~3, ~4
          6        ECHO                                                     ~5
          7      > RETURN                                                   null

End of function peek

Function out:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  out
number of ops:  7
compiled vars:  !0 = $pref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        CONCAT                                           ~1      '%0A', !0
          2        CONCAT                                           ~2      ~1, '%3A%3A%24baz+%3D+'
          3        FETCH_OBJ_R                                      ~3      'baz'
          4        CONCAT                                           ~4      ~2, ~3
          5        ECHO                                                     ~4
    6     6      > RETURN                                                   null

End of function out

End of class Foo.

Class Bar:
Function peek:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  peek
number of ops:  8
compiled vars:  !0 = $target, !1 = $pref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        CONCAT                                           ~2      '%0Apeek+%40', !1
          3        CONCAT                                           ~3      ~2, '%3A%3A%24baz+%3D+'
          4        FETCH_OBJ_R                                      ~4      !0, 'baz'
          5        CONCAT                                           ~5      ~3, ~4
          6        ECHO                                                     ~5
   15     7      > RETURN                                                   null

End of function peek

Function mess:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  mess
number of ops:  4
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        ASSIGN_OBJ                                               !0, 'baz'
          2        OP_DATA                                                  'cats'
   18     3      > RETURN                                                   null

End of function mess

Function out:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c3Q9E
function name:  out
number of ops:  7
compiled vars:  !0 = $pref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        CONCAT                                           ~1      '%0A', !0
          2        CONCAT                                           ~2      ~1, '%3A%3A%24baz+%3D+'
          3        FETCH_OBJ_R                                      ~3      'baz'
          4        CONCAT                                           ~4      ~2, ~3
          5        ECHO                                                     ~4
    6     6      > RETURN                                                   null

End of function out

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.35 ms | 1403 KiB | 13 Q