3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $foo; public function __construct($foo) { $this->foo = $foo; } private function bar() { echo 'Accessed the private method.'; } } class Test2 { public function baz(Test $other) { // We can change the private property: $other->foo = 'hello'; var_dump($other->foo); // We can also call the private method: $other->bar(); } } $test = new Test2('test'); $test->baz(new Test('other'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KM1W2
function name:  (null)
number of ops:  11
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'Test2'
          1        SEND_VAL_EX                                              'test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   34     4        INIT_METHOD_CALL                                         !0, 'baz'
          5        NEW                                              $4      'Test'
          6        SEND_VAL_EX                                              'other'
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $4
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KM1W2
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KM1W2
function name:  bar
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ECHO                                                     'Accessed+the+private+method.'
   15     1      > RETURN                                                   null

End of function bar

End of class Test.

Class Test2:
Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KM1W2
function name:  baz
number of ops:  10
compiled vars:  !0 = $other
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   24     1        ASSIGN_OBJ                                               !0, 'foo'
          2        OP_DATA                                                  'hello'
   25     3        INIT_FCALL                                               'var_dump'
          4        FETCH_OBJ_R                                      ~2      !0, 'foo'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                                 
   28     7        INIT_METHOD_CALL                                         !0, 'bar'
          8        DO_FCALL                                      0          
   29     9      > RETURN                                                   null

End of function baz

End of class Test2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.14 ms | 1396 KiB | 15 Q