3v4l.org

run code in 300+ PHP versions simultaneously
<?php /// Example 1 $str = "Simple text"; $a = function() { global $str; $str = "edited"; }; $a(); echo $str."\n"; /// edited /// Example 2 $str = "Simple text"; $a = function() { $GLOBALS["str"] = "edited"; }; $a(); echo $str."\n"; /// edited /// Example 3 $str = "Simple text"; $temp = ""; $a = function() { $GLOBALS["temp"] = &$GLOBALS["str"]; }; $a(); echo "[".$str."] [".$temp."]\n"; /// [Simple text] [Simple text] /// Example 4 $str = "Simple text"; $temp = ""; $a = function() { global $str, $temp; $temp = &$str; }; $a(); echo "[".$str."] [".$temp."]\n"; /// [Simple text] []
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/emave
function name:  (null)
number of ops:  37
compiled vars:  !0 = $str, !1 = $a, !2 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'Simple+text'
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Femave%3A5%240'
          2        ASSIGN                                                   !1, ~4
   10     3        INIT_DYNAMIC_CALL                                        !1
          4        DO_FCALL                                      0          
   11     5        CONCAT                                           ~7      !0, '%0A'
          6        ECHO                                                     ~7
   14     7        ASSIGN                                                   !0, 'Simple+text'
   15     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Femave%3A15%241'
          9        ASSIGN                                                   !1, ~9
   19    10        INIT_DYNAMIC_CALL                                        !1
         11        DO_FCALL                                      0          
   20    12        CONCAT                                           ~12     !0, '%0A'
         13        ECHO                                                     ~12
   23    14        ASSIGN                                                   !0, 'Simple+text'
   24    15        ASSIGN                                                   !2, ''
   25    16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Femave%3A25%242'
         17        ASSIGN                                                   !1, ~15
   29    18        INIT_DYNAMIC_CALL                                        !1
         19        DO_FCALL                                      0          
   30    20        CONCAT                                           ~18     '%5B', !0
         21        CONCAT                                           ~19     ~18, '%5D+%5B'
         22        CONCAT                                           ~20     ~19, !2
         23        CONCAT                                           ~21     ~20, '%5D%0A'
         24        ECHO                                                     ~21
   33    25        ASSIGN                                                   !0, 'Simple+text'
   34    26        ASSIGN                                                   !2, ''
   35    27        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Femave%3A35%243'
         28        ASSIGN                                                   !1, ~24
   40    29        INIT_DYNAMIC_CALL                                        !1
         30        DO_FCALL                                      0          
   41    31        CONCAT                                           ~27     '%5B', !0
         32        CONCAT                                           ~28     ~27, '%5D+%5B'
         33        CONCAT                                           ~29     ~28, !2
         34        CONCAT                                           ~30     ~29, '%5D%0A'
         35        ECHO                                                     ~30
         36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Femave%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/emave
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   BIND_GLOBAL                                              !0, 'str'
    8     1        ASSIGN                                                   !0, 'edited'
    9     2      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Femave%3A5%240

Function %00%7Bclosure%7D%2Fin%2Femave%3A15%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/emave
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_W                      global              $0      'GLOBALS'
          1        ASSIGN_DIM                                               $0, 'str'
          2        OP_DATA                                                  'edited'
   18     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Femave%3A15%241

Function %00%7Bclosure%7D%2Fin%2Femave%3A25%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/emave
function name:  {closure}
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_W                      global              $2      'GLOBALS'
          1        FETCH_DIM_W                                      $3      $2, 'str'
          2        MAKE_REF                                         $4      $3
          3        FETCH_W                      global              $0      'GLOBALS'
          4        FETCH_DIM_W                                      $1      $0, 'temp'
          5        ASSIGN_REF                                               $1, $4
   28     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Femave%3A25%242

Function %00%7Bclosure%7D%2Fin%2Femave%3A35%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/emave
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $str, !1 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   BIND_GLOBAL                                              !0, 'str'
          1        BIND_GLOBAL                                              !1, 'temp'
   38     2        ASSIGN_REF                                               !1, !0
   39     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Femave%3A35%243

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.01 ms | 1399 KiB | 13 Q