3v4l.org

run code in 300+ PHP versions simultaneously
<?php function modify_in_place_by_ref(&$prices) { $prices[0] = 100; } function modify_location_by_ref(&$prices) { $prices = [40, 50, 60]; } $prices = [1, 2, 3]; modify_in_place_by_ref($prices); if ($prices[0] == 100) { echo "Pass-by-reference!\n"; // Yep } else { echo "Pass-by-value!\n"; } $prices = [1, 2, 3]; modify_location($prices); if ($prices[0] == 40) { echo "Pass-by-reference!\n"; // Yep } else { echo "Pass-by-value!\n"; }
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
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
Branch analysis from position: 19
filename:       /in/8tDef
function name:  (null)
number of ops:  21
compiled vars:  !0 = $prices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'modify_in_place_by_ref'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
   12     4        FETCH_DIM_R                                      ~3      !0, 0
          5        IS_EQUAL                                                 ~3, 100
          6      > JMPZ                                                     ~4, ->9
   13     7    >   ECHO                                                     'Pass-by-reference%21%0A'
          8      > JMP                                                      ->10
   15     9    >   ECHO                                                     'Pass-by-value%21%0A'
   18    10    >   ASSIGN                                                   !0, <array>
   19    11        INIT_FCALL_BY_NAME                                       'modify_location'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
   20    14        FETCH_DIM_R                                      ~7      !0, 0
         15        IS_EQUAL                                                 ~7, 40
         16      > JMPZ                                                     ~8, ->19
   21    17    >   ECHO                                                     'Pass-by-reference%21%0A'
         18      > JMP                                                      ->20
   23    19    >   ECHO                                                     'Pass-by-value%21%0A'
   24    20    > > RETURN                                                   1

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

End of function modify_in_place_by_ref

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

End of function modify_location_by_ref

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.45 ms | 1403 KiB | 14 Q