3v4l.org

run code in 300+ PHP versions simultaneously
<?php function retVal() { global $foo; return $foo; } function & retRef() { global $foo; return $foo; } unset($foo, $bar); $foo = 'init'; $bar = retVal(); $bar = 'bar'; var_dump($foo, $bar); unset($foo, $bar); $foo = 'init'; $bar = retRef(); $bar = 'bar'; var_dump($foo, $bar); unset($foo, $bar); $foo = 'init'; $bar = & retVal(); $bar = 'bar'; var_dump($foo, $bar); unset($foo, $bar); $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/ARuTT
function name:  (null)
number of ops:  45
compiled vars:  !0 = $foo, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   UNSET_CV                                                 !0
          1        UNSET_CV                                                 !1
   16     2        ASSIGN                                                   !0, 'init'
   17     3        INIT_FCALL                                               'retval'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   18     6        ASSIGN                                                   !1, 'bar'
   19     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   21    11        UNSET_CV                                                 !0
         12        UNSET_CV                                                 !1
   22    13        ASSIGN                                                   !0, 'init'
   23    14        INIT_FCALL                                               'retref'
         15        DO_FCALL                                      0  $8      
         16        ASSIGN                                                   !1, $8
   24    17        ASSIGN                                                   !1, 'bar'
   25    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
   27    22        UNSET_CV                                                 !0
         23        UNSET_CV                                                 !1
   28    24        ASSIGN                                                   !0, 'init'
   29    25        INIT_FCALL                                               'retval'
         26        DO_FCALL                                      0  $13     
         27        ASSIGN_REF                                               !1, $13
   30    28        ASSIGN                                                   !1, 'bar'
   31    29        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !0
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
   33    33        UNSET_CV                                                 !0
         34        UNSET_CV                                                 !1
   34    35        ASSIGN                                                   !0, 'init'
   35    36        INIT_FCALL                                               'retref'
         37        DO_FCALL                                      0  $18     
         38        ASSIGN_REF                                               !1, $18
   36    39        ASSIGN                                                   !1, 'bar'
   37    40        INIT_FCALL                                               'var_dump'
         41        SEND_VAR                                                 !0
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Function retval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ARuTT
function name:  retVal
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                                                   !0
    7     2*     > RETURN                                                   null

End of function retval

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

End of function retref

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.13 ms | 1403 KiB | 19 Q