3v4l.org

run code in 300+ PHP versions simultaneously
<?php function passByReference(&$test) { $test = "Changed!"; } function passByValue($test) { $test = "a change here will not affect the original variable"; } $test = 'Unchanged'; echo $test . PHP_EOL; passByValue($test); echo $test . PHP_EOL; passByReference($test); echo $test . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRFZh
function name:  (null)
number of ops:  14
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, 'Unchanged'
   12     1        CONCAT                                           ~2      !0, '%0A'
          2        ECHO                                                     ~2
   14     3        INIT_FCALL                                               'passbyvalue'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
   15     6        CONCAT                                           ~4      !0, '%0A'
          7        ECHO                                                     ~4
   17     8        INIT_FCALL                                               'passbyreference'
          9        SEND_REF                                                 !0
         10        DO_FCALL                                      0          
   18    11        CONCAT                                           ~6      !0, '%0A'
         12        ECHO                                                     ~6
         13      > RETURN                                                   1

Function passbyreference:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRFZh
function name:  passByReference
number of ops:  3
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !0, 'Changed%21'
    5     2      > RETURN                                                   null

End of function passbyreference

Function passbyvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XRFZh
function name:  passByValue
number of ops:  3
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !0, 'a+change+here+will+not+affect+the+original+variable'
    9     2      > RETURN                                                   null

End of function passbyvalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.11 ms | 1398 KiB | 15 Q