3v4l.org

run code in 300+ PHP versions simultaneously
<?php $var1 = "Example variable"; $var2 = ""; function global_references($use_globals) { global $var1, $var2; if (!$use_globals) { $var2 =& $var1; // visible only inside the function } else { $GLOBALS["var2"] =& $var1; // visible also in global context } } global_references(false); echo "var2 is set to '$var2'\n"; // var2 is set to '' global_references(true); echo "var2 is set to '$var2'\n"; // var2 is set to 'Example variable' ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CZ4BT
function name:  (null)
number of ops:  17
compiled vars:  !0 = $var1, !1 = $var2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Example+variable'
    3     1        ASSIGN                                                   !1, ''
   15     2        INIT_FCALL                                               'global_references'
          3        SEND_VAL                                                 <false>
          4        DO_FCALL                                      0          
   16     5        ROPE_INIT                                     3  ~6      'var2+is+set+to+%27'
          6        ROPE_ADD                                      1  ~6      ~6, !1
          7        ROPE_END                                      2  ~5      ~6, '%27%0A'
          8        ECHO                                                     ~5
   17     9        INIT_FCALL                                               'global_references'
         10        SEND_VAL                                                 <true>
         11        DO_FCALL                                      0          
   18    12        ROPE_INIT                                     3  ~10     'var2+is+set+to+%27'
         13        ROPE_ADD                                      1  ~10     ~10, !1
         14        ROPE_END                                      2  ~9      ~10, '%27%0A'
         15        ECHO                                                     ~9
   19    16      > RETURN                                                   1

Function global_references:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CZ4BT
function name:  global_references
number of ops:  11
compiled vars:  !0 = $use_globals, !1 = $var1, !2 = $var2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        BIND_GLOBAL                                              !1, 'var1'
          2        BIND_GLOBAL                                              !2, 'var2'
    8     3        BOOL_NOT                                         ~3      !0
          4      > JMPZ                                                     ~3, ->7
    9     5    >   ASSIGN_REF                                               !2, !1
          6      > JMP                                                      ->10
   11     7    >   FETCH_W                      global              $5      'GLOBALS'
          8        FETCH_DIM_W                                      $6      $5, 'var2'
          9        ASSIGN_REF                                               $6, !1
   13    10    > > RETURN                                                   null

End of function global_references

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.83 ms | 1399 KiB | 15 Q