3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait Counter { public static function inc() { static $c = 0; $c = $c + 1; echo "$c\n"; } } Counter::inc(); class C1 { use Counter; } C1::inc(); C1::inc(); class C2 { use Counter; } C2::inc();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Oqrgt
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   INIT_STATIC_METHOD_CALL                                      'Counter', 'inc'
          1        DO_FCALL                                          0          
   14     2        DECLARE_CLASS                                                'c1'
   18     3        INIT_STATIC_METHOD_CALL                                      'C1', 'inc'
          4        DO_FCALL                                          0          
   19     5        INIT_STATIC_METHOD_CALL                                      'C1', 'inc'
          6        DO_FCALL                                          0          
   22     7        DECLARE_CLASS                                                'c2'
   27     8        INIT_STATIC_METHOD_CALL                                      'C2', 'inc'
          9        DO_FCALL                                          0          
         10      > RETURN                                                       1

Class Counter:
Function inc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Oqrgt
function name:  inc
number of ops:  7
compiled vars:  !0 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                                  !0
    7     1        ADD                                                  ~1      !0, 1
          2        ASSIGN                                                       !0, ~1
    8     3        NOP                                                          
          4        FAST_CONCAT                                          ~3      !0, '%0A'
          5        ECHO                                                         ~3
    9     6      > RETURN                                                       null

End of function inc

End of class Counter.

Class C1: [no user functions]
Class C2: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
213.84 ms | 3148 KiB | 13 Q