3v4l.org

run code in 300+ PHP versions simultaneously
<?php function & retRef() { global $foo; return $foo; } // don't assign by reference doesn't result in a reference $foo = 'init'; $bar = retRef(); $bar = 'bar'; var_dump($foo, $bar); // reset variables unset($foo, $bar); // requires to assign the function call by reference $foo = 'init'; $bar = & retRef(); $bar = 'bar'; var_dump($foo, $bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i79WC
function name:  (null)
number of ops:  21
compiled vars:  !0 = $foo, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 'init'
   11     1        INIT_FCALL                                               'retref'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   12     4        ASSIGN                                                   !1, 'bar'
   13     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   16     9        UNSET_CV                                                 !0
         10        UNSET_CV                                                 !1
   19    11        ASSIGN                                                   !0, 'init'
   20    12        INIT_FCALL                                               'retref'
         13        DO_FCALL                                      0  $8      
         14        ASSIGN_REF                                               !1, $8
   21    15        ASSIGN                                                   !1, 'bar'
   22    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function retref:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/i79WC
function name:  retRef
number of ops:  3
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_GLOBAL                                              !0, 'foo'
    6     1      > RETURN_BY_REF                                            !0
    7     2*     > RETURN_BY_REF                                            null

End of function retref

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.62 ms | 1398 KiB | 17 Q