3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ancestor { public $publicVar = "ancestor's public var\n"; static $statisVar = "ancestor's static var\n"; function publicMethod(){ echo "this is ancestor's public method\n"; // is $this is set up if(isset($this)){ echo "publicMethod is in object context\n"; }else{ echo "publicMethod is in static context\n"; } } static function staticMethod(){ echo "this is ancestor's static method\n"; // is $this is set up if(isset($this)){ echo "staticMethod is in object context\n"; }else{ echo "staticMethod is in static context\n"; } } } class Descendant extends Ancestor { public $publicVar = "descendant's public var\n"; static $staticVar = "descendant's static var\n"; function publicMethod(){ echo "this is descendant's public method\n"; // is $this is set up if(isset($this)){ echo "publicMethod is in object context\n"; }else{ echo "publicMethod is in static context\n"; } } static function staticMethod(){ echo "this is descendant's static method\n"; // is $this is set up if(isset($this)){ echo "staticMethod is in object context\n"; }else{ echo "staticMethod is in static context\n"; } } } $ancestor = new Ancestor(); $descendant = new Descendant(); // From Outside Of An Instance/Class: echo $ancestor->publicVar; echo $ancestor::staticVar; echo $descendant->publicVar; echo $ancestor::staticVar; //Ancestor::publicMethod();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RottT
function name:  (null)
number of ops:  17
compiled vars:  !0 = $ancestor, !1 = $descendant
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   NEW                                              $2      'Ancestor'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   52     3        NEW                                              $5      'Descendant'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   55     6        FETCH_OBJ_R                                      ~8      !0, 'publicVar'
          7        ECHO                                                     ~8
   56     8        FETCH_CLASS                                   0  $9      !0
          9        FETCH_CLASS_CONSTANT                             ~10     $9, 'staticVar'
         10        ECHO                                                     ~10
   57    11        FETCH_OBJ_R                                      ~11     !1, 'publicVar'
         12        ECHO                                                     ~11
   58    13        FETCH_CLASS                                   0  $12     !0
         14        FETCH_CLASS_CONSTANT                             ~13     $12, 'staticVar'
         15        ECHO                                                     ~13
   61    16      > RETURN                                                   1

Class Ancestor:
Function publicmethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RottT
function name:  publicMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'this+is+ancestor%27s+public+method%0A'
    8     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
    9     3    >   ECHO                                                     'publicMethod+is+in+object+context%0A'
          4      > JMP                                                      ->6
   11     5    >   ECHO                                                     'publicMethod+is+in+static+context%0A'
   13     6    > > RETURN                                                   null

End of function publicmethod

Function staticmethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RottT
function name:  staticMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     'this+is+ancestor%27s+static+method%0A'
   18     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
   19     3    >   ECHO                                                     'staticMethod+is+in+object+context%0A'
          4      > JMP                                                      ->6
   21     5    >   ECHO                                                     'staticMethod+is+in+static+context%0A'
   23     6    > > RETURN                                                   null

End of function staticmethod

End of class Ancestor.

Class Descendant:
Function publicmethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RottT
function name:  publicMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                     'this+is+descendant%27s+public+method%0A'
   33     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
   34     3    >   ECHO                                                     'publicMethod+is+in+object+context%0A'
          4      > JMP                                                      ->6
   36     5    >   ECHO                                                     'publicMethod+is+in+static+context%0A'
   38     6    > > RETURN                                                   null

End of function publicmethod

Function staticmethod:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RottT
function name:  staticMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ECHO                                                     'this+is+descendant%27s+static+method%0A'
   43     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
   44     3    >   ECHO                                                     'staticMethod+is+in+object+context%0A'
          4      > JMP                                                      ->6
   46     5    >   ECHO                                                     'staticMethod+is+in+static+context%0A'
   48     6    > > RETURN                                                   null

End of function staticmethod

End of class Descendant.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.25 ms | 1399 KiB | 13 Q