3v4l.org

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

Class Counter:
Function inc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0T68G
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:
152.41 ms | 1394 KiB | 13 Q