3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); const INITIAL_STATE = [1, 1]; function &__globalState(): array { static $state = INITIAL_STATE; return $state; } function test() { $state = __globalState(); $state[0]++; } test(); test(); var_dump(__globalState());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IO4hA
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'INITIAL_STATE', <array>
   17     1        INIT_FCALL                                               'test'
          2        DO_FCALL                                      0          
   18     3        INIT_FCALL                                               'test'
          4        DO_FCALL                                      0          
   20     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               '__globalstate'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function __globalstate:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/IO4hA
function name:  __globalState
number of ops:  7
compiled vars:  !0 = $state
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ZEND_BIND_INIT_STATIC_OR_JMP                             !0
          1        FETCH_CONSTANT                                   ~1      'INITIAL_STATE'
          2        BIND_STATIC                                              !0, ~1
    8     3        VERIFY_RETURN_TYPE                                       !0
          4      > RETURN_BY_REF                                            !0
    9     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN_BY_REF                                            null

End of function __globalstate

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IO4hA
function name:  test
number of ops:  6
compiled vars:  !0 = $state
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               '__globalstate'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   14     3        FETCH_DIM_RW                                     $3      !0, 0
          4        PRE_INC                                                  $3
   15     5      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.44 ms | 1001 KiB | 18 Q