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); echo (bool)($prices[0] == 100); //failed! 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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VVKSm
function name:  (null)
number of ops:  20
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                                         ~4      ~3, 100
          6        BOOL                                             ~5      ~4
          7        ECHO                                                     ~5
   15     8        ASSIGN                                                   !0, <array>
   16     9        INIT_FCALL                                               'modify_location'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0          
   17    12        ASSERT_CHECK                                             
         13        INIT_FCALL                                               'assert'
         14        FETCH_DIM_R                                      ~8      !0, 0
         15        IS_EQUAL                                         ~9      ~8, 40
         16        SEND_VAL                                                 ~9
         17        SEND_VAL                                                 'assert%28%24prices%5B0%5D+%3D%3D+40%29'
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function modify_in_place:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VVKSm
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/VVKSm
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:
167.24 ms | 1399 KiB | 17 Q