3v4l.org

run code in 300+ 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(); class C2 { use Counter; } C2::inc();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PQQ8m
function name:  (null)
number of ops:  9
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          
   21     5        DECLARE_CLASS                                            'c2'
   26     6        INIT_STATIC_METHOD_CALL                                  'C2', 'inc'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Class Counter:
Function inc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PQQ8m
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.0.0


preferences:
155.81 ms | 1394 KiB | 13 Q