3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ancestor { public $publicVar = "ancestor's public var\n"; static $staticVar = "ancestor's static var\n"; function publicMethod(){ echo "ancestor's publicMethod "; // is $this is set up if(isset($this)){ echo "is in object context\n"; }else{ echo "is in static context\n"; } } static function staticMethod(){ echo "ancestor's staticMethod "; // is $this is set up if(isset($this)){ echo "in object context\n"; }else{ echo "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 "descendant's publicMethod "; // is $this is set up if(isset($this)){ echo "in object context\n"; }else{ echo "in static context\n"; } } static function staticMethod(){ echo "descendant's staticMethod "; // is $this is set up if(isset($this)){ echo "in object context\n"; }else{ echo "in static context\n"; } } } $ancestor = new Ancestor(); $descendant = new Descendant(); // From Outside Of An Instance/Class: // access to properties echo $descendant->publicVar; // descendant's public var //echo $descendant->staticVar; // "" + notice: Undefined property: Descendant::$staticVar echo $descendant::$staticVar; // descendant's static var //echo $descendant::$publicVar; // fatal error: Access to undeclared static property: Descendant::$publicVar //echo Descendant::$publicVar; // fatal error: Access to undeclared static property echo Descendant::$staticVar; // descendant's static var // access to methods $descendant->publicMethod(); // descendant's publicMethod in object context $descendant->staticMethod(); // descendant's staticMethod in static context $descendant::staticMethod(); // descendant's staticMethod in static context $descendant::publicMethod(); // descendant's publicMethod in static context Descendant::publicMethod(); // Descendant::staticMethod(); // //Ancestor::publicMethod();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uqDYj
function name:  (null)
number of ops:  28
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
   56     6        FETCH_OBJ_R                                      ~8      !1, 'publicVar'
          7        ECHO                                                     ~8
   58     8        FETCH_CLASS                                   0  $9      !1
          9        FETCH_STATIC_PROP_R          unknown             ~10     'staticVar'
         10        ECHO                                                     ~10
   62    11        FETCH_STATIC_PROP_R          unknown             ~11     'staticVar'
         12        ECHO                                                     ~11
   65    13        INIT_METHOD_CALL                                         !1, 'publicMethod'
         14        DO_FCALL                                      0          
   66    15        INIT_METHOD_CALL                                         !1, 'staticMethod'
         16        DO_FCALL                                      0          
   67    17        FETCH_CLASS                                   0  $14     !1
         18        INIT_STATIC_METHOD_CALL                                  $14, 'staticMethod'
         19        DO_FCALL                                      0          
   68    20        FETCH_CLASS                                   0  $16     !1
         21        INIT_STATIC_METHOD_CALL                                  $16, 'publicMethod'
         22        DO_FCALL                                      0          
   70    23        INIT_STATIC_METHOD_CALL                                  'Descendant', 'publicMethod'
         24        DO_FCALL                                      0          
   71    25        INIT_STATIC_METHOD_CALL                                  'Descendant', 'staticMethod'
         26        DO_FCALL                                      0          
   73    27      > 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/uqDYj
function name:  publicMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'ancestor%27s+publicMethod+'
    8     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
    9     3    >   ECHO                                                     'is+in+object+context%0A'
          4      > JMP                                                      ->6
   11     5    >   ECHO                                                     '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/uqDYj
function name:  staticMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     'ancestor%27s+staticMethod+'
   18     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
   19     3    >   ECHO                                                     'in+object+context%0A'
          4      > JMP                                                      ->6
   21     5    >   ECHO                                                     '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/uqDYj
function name:  publicMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                     'descendant%27s+publicMethod+'
   33     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
   34     3    >   ECHO                                                     'in+object+context%0A'
          4      > JMP                                                      ->6
   36     5    >   ECHO                                                     '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/uqDYj
function name:  staticMethod
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ECHO                                                     'descendant%27s+staticMethod+'
   43     1        ISSET_ISEMPTY_THIS                               ~0      
          2      > JMPZ                                                     ~0, ->5
   44     3    >   ECHO                                                     'in+object+context%0A'
          4      > JMP                                                      ->6
   46     5    >   ECHO                                                     '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:
139.46 ms | 1399 KiB | 13 Q