3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 1; $x = 2; function test() { global $a; global $x; $GLOBALS['a'] = &$x; $x = 5; echo $a . PHP_EOL; echo $x . PHP_EOL; } test(); echo PHP_EOL; echo $a . PHP_EOL; // $a is 1 here instead of 5 echo $x . PHP_EOL; $a = &$x; echo PHP_EOL; echo $a . PHP_EOL; echo $x . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dSDPb
function name:  (null)
number of ops:  16
compiled vars:  !0 = $a, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1
    4     1        ASSIGN                                                   !1, 2
   16     2        INIT_FCALL                                               'test'
          3        DO_FCALL                                      0          
   18     4        ECHO                                                     '%0A'
   19     5        CONCAT                                           ~5      !0, '%0A'
          6        ECHO                                                     ~5
   20     7        CONCAT                                           ~6      !1, '%0A'
          8        ECHO                                                     ~6
   22     9        ASSIGN_REF                                               !0, !1
   24    10        ECHO                                                     '%0A'
   25    11        CONCAT                                           ~8      !0, '%0A'
         12        ECHO                                                     ~8
   26    13        CONCAT                                           ~9      !1, '%0A'
         14        ECHO                                                     ~9
   27    15      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dSDPb
function name:  test
number of ops:  10
compiled vars:  !0 = $a, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_GLOBAL                                              !0, 'a'
    7     1        BIND_GLOBAL                                              !1, 'x'
    9     2        FETCH_W                      global              $2      'a'
          3        ASSIGN_REF                                               $2, !1
   10     4        ASSIGN                                                   !1, 5
   12     5        CONCAT                                           ~5      !0, '%0A'
          6        ECHO                                                     ~5
   13     7        CONCAT                                           ~6      !1, '%0A'
          8        ECHO                                                     ~6
   14     9      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
253.2 ms | 1003 KiB | 14 Q