3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected static $member_counter = 0; public static function counter() { static $counter = 0; $counter++; return $counter; } public static function member_counter(){ static::$member_counter++; return static::$member_counter; } } class B extends A { protected static $member_counter = 0; } var_dump(A::counter()); // int(1) var_dump(A::counter()); // int(2) var_dump(B::counter()); // int(3), previously int(1) var_dump(B::counter()); // int(4), previously int(2) echo '======================='.PHP_EOL; var_dump(A::member_counter()); // int(1) var_dump(A::member_counter()); // int(2) var_dump(B::member_counter()); // int(1) var_dump(B::member_counter()); // int(2)
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aWqn0
function name:  (null)
number of ops:  42
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_STATIC_METHOD_CALL                                  'A', 'counter'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
   19     5        INIT_FCALL                                               'var_dump'
          6        INIT_STATIC_METHOD_CALL                                  'A', 'counter'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
   20    10        INIT_FCALL                                               'var_dump'
         11        INIT_STATIC_METHOD_CALL                                  'B', 'counter'
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
   21    15        INIT_FCALL                                               'var_dump'
         16        INIT_STATIC_METHOD_CALL                                  'B', 'counter'
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
   22    20        ECHO                                                     '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A'
   23    21        INIT_FCALL                                               'var_dump'
         22        INIT_STATIC_METHOD_CALL                                  'A', 'member_counter'
         23        DO_FCALL                                      0  $8      
         24        SEND_VAR                                                 $8
         25        DO_ICALL                                                 
   24    26        INIT_FCALL                                               'var_dump'
         27        INIT_STATIC_METHOD_CALL                                  'A', 'member_counter'
         28        DO_FCALL                                      0  $10     
         29        SEND_VAR                                                 $10
         30        DO_ICALL                                                 
   25    31        INIT_FCALL                                               'var_dump'
         32        INIT_STATIC_METHOD_CALL                                  'B', 'member_counter'
         33        DO_FCALL                                      0  $12     
         34        SEND_VAR                                                 $12
         35        DO_ICALL                                                 
   26    36        INIT_FCALL                                               'var_dump'
         37        INIT_STATIC_METHOD_CALL                                  'B', 'member_counter'
         38        DO_FCALL                                      0  $14     
         39        SEND_VAR                                                 $14
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Class A:
Function counter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aWqn0
function name:  counter
number of ops:  4
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
    7     1        PRE_INC                                                  !0
    8     2      > RETURN                                                   !0
    9     3*     > RETURN                                                   null

End of function counter

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

End of function member_counter

End of class A.

Class B:
Function counter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aWqn0
function name:  counter
number of ops:  4
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
    7     1        PRE_INC                                                  !0
    8     2      > RETURN                                                   !0
    9     3*     > RETURN                                                   null

End of function counter

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

End of function member_counter

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.99 ms | 1007 KiB | 14 Q