3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &returnRef() { global $a; return $a; } function returnVal() { global $a; return $a; } $a = "original"; $b =& returnVal(); $b = "changed"; var_dump($a); //expecting warning + "original" $a = "original"; $b =& returnRef(); $b = "changed"; var_dump($a); //expecting "changed"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mRBD3
function name:  (null)
number of ops:  17
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 'original'
   13     1        INIT_FCALL                                               'returnval'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN_REF                                               !1, $3
   14     4        ASSIGN                                                   !1, 'changed'
   15     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   17     8        ASSIGN                                                   !0, 'original'
   18     9        INIT_FCALL                                               'returnref'
         10        DO_FCALL                                      0  $8      
         11        ASSIGN_REF                                               !1, $8
   19    12        ASSIGN                                                   !1, 'changed'
   20    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

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

End of function returnref

Function returnval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mRBD3
function name:  returnVal
number of ops:  3
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   BIND_GLOBAL                                              !0, 'a'
    9     1      > RETURN                                                   !0
   10     2*     > RETURN                                                   null

End of function returnval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.43 ms | 1399 KiB | 17 Q