3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function getThis() { return $this; } private function getThisPrivate() { return $this; } private function helloWorld() { echo "Hello, World!"; } private function chainPublic() { return $this->getThis()->helloWorld(); } private function chainPrivate() { return $this->getThisPrivate()->helloWorld(); } } $foo = new Foo; $foo->chainPublic(); // Hello, World! $foo->chainPrivate(); // Fails?
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ejQD
function name:  (null)
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   12     3        INIT_METHOD_CALL                                         !0, 'chainPublic'
          4        DO_FCALL                                      0          
   13     5        INIT_METHOD_CALL                                         !0, 'chainPrivate'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class Foo:
Function getthis:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ejQD
function name:  getThis
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   FETCH_THIS                                       ~0      
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getthis

Function getthisprivate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ejQD
function name:  getThisPrivate
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_THIS                                       ~0      
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getthisprivate

Function helloworld:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ejQD
function name:  helloWorld
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'Hello%2C+World%21'
          1      > RETURN                                                   null

End of function helloworld

Function chainpublic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ejQD
function name:  chainPublic
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'getThis'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'helloWorld'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function chainpublic

Function chainprivate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ejQD
function name:  chainPrivate
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_METHOD_CALL                                         'getThisPrivate'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'helloWorld'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function chainprivate

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.49 ms | 1399 KiB | 13 Q