3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public static $my_static = 'foo'; public function staticValue() { return self::$my_static; } } class Bar extends Foo { public function fooStatic() { return parent::$my_static; } } print Foo::$my_static . "\n"; $foo = new Foo(); print $foo->staticValue() . "\n"; print $foo->my_static . "\n"; // Undefined "Property" my_static print $foo::$my_static . "\n"; $classname = 'Foo'; print $classname::$my_static . "\n"; // As of PHP 5.3.0 print Bar::$my_static . "\n"; $bar = new Bar(); print $bar->fooStatic() . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sRKR9
function name:  (null)
number of ops:  33
compiled vars:  !0 = $foo, !1 = $classname, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_STATIC_PROP_R          unknown             ~3      'my_static'
          1        CONCAT                                           ~4      ~3, '%0A'
          2        ECHO                                                     ~4
   21     3        NEW                                              $5      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $5
   22     6        INIT_METHOD_CALL                                         !0, 'staticValue'
          7        DO_FCALL                                      0  $8      
          8        CONCAT                                           ~9      $8, '%0A'
          9        ECHO                                                     ~9
   23    10        FETCH_OBJ_R                                      ~10     !0, 'my_static'
         11        CONCAT                                           ~11     ~10, '%0A'
         12        ECHO                                                     ~11
   25    13        FETCH_CLASS                                   0  $12     !0
         14        FETCH_STATIC_PROP_R          unknown             ~13     'my_static'
         15        CONCAT                                           ~14     ~13, '%0A'
         16        ECHO                                                     ~14
   26    17        ASSIGN                                                   !1, 'Foo'
   27    18        FETCH_CLASS                                   0  $16     !1
         19        FETCH_STATIC_PROP_R          unknown             ~17     'my_static'
         20        CONCAT                                           ~18     ~17, '%0A'
         21        ECHO                                                     ~18
   29    22        FETCH_STATIC_PROP_R          unknown             ~19     'my_static'
         23        CONCAT                                           ~20     ~19, '%0A'
         24        ECHO                                                     ~20
   30    25        NEW                                              $21     'Bar'
         26        DO_FCALL                                      0          
         27        ASSIGN                                                   !2, $21
   31    28        INIT_METHOD_CALL                                         !2, 'fooStatic'
         29        DO_FCALL                                      0  $24     
         30        CONCAT                                           ~25     $24, '%0A'
         31        ECHO                                                     ~25
         32      > RETURN                                                   1

Class Foo:
Function staticvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sRKR9
function name:  staticValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'my_static'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function staticvalue

End of class Foo.

Class Bar:
Function foostatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sRKR9
function name:  fooStatic
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'my_static'
          1      > RETURN                                                   ~0
   15     2*     > RETURN                                                   null

End of function foostatic

Function staticvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sRKR9
function name:  staticValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'my_static'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function staticvalue

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.79 ms | 1399 KiB | 13 Q