3v4l.org

run code in 300+ PHP versions simultaneously
<?php function modify_in_place($prices) { $prices[0] = 100; } function modify_location($prices) { $prices = [40, 50, 60]; } $prices = [1, 2, 3]; modify_in_place($prices); if ($prices[0] == 100) { echo "Pass-by-reference!"; } else { echo "Pass-by-value!"; } $prices = [1, 2, 3]; modify_location($prices); assert($prices[0] == 40); //failed! pass-by-value
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fW2T3
function name:  (null)
number of ops:  22
compiled vars:  !0 = $prices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'modify_in_place'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
   13     4        FETCH_DIM_R                                      ~3      !0, 0
          5        IS_EQUAL                                                 ~3, 100
          6      > JMPZ                                                     ~4, ->9
   14     7    >   ECHO                                                     'Pass-by-reference%21'
          8      > JMP                                                      ->10
   16     9    >   ECHO                                                     'Pass-by-value%21'
   21    10    >   ASSIGN                                                   !0, <array>
   22    11        INIT_FCALL                                               'modify_location'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0          
   23    14        ASSERT_CHECK                                             
         15        INIT_FCALL                                               'assert'
         16        FETCH_DIM_R                                      ~7      !0, 0
         17        IS_EQUAL                                         ~8      ~7, 40
         18        SEND_VAL                                                 ~8
         19        SEND_VAL                                                 'assert%28%24prices%5B0%5D+%3D%3D+40%29'
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function modify_in_place:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fW2T3
function name:  modify_in_place
number of ops:  4
compiled vars:  !0 = $prices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN_DIM                                               !0, 0
          2        OP_DATA                                                  100
    5     3      > RETURN                                                   null

End of function modify_in_place

Function modify_location:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fW2T3
function name:  modify_location
number of ops:  3
compiled vars:  !0 = $prices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !0, <array>
    9     2      > RETURN                                                   null

End of function modify_location

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.51 ms | 1399 KiB | 17 Q