3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addOrIncr(&$arr, $key, $value) { $arr[$key] = ($arr[$key] ?? 0) + $value; } $arr = ['foo' => 1]; $value = 10; $key = 'foo'; $arr[$key] = ($arr[$key] ?? 0) + $value; $key = 'bar'; $arr[$key] = ($arr[$key] ?? 0) + $value; var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ke0po
function name:  (null)
number of ops:  20
compiled vars:  !0 = $arr, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, 10
    9     2        ASSIGN                                                   !2, 'foo'
   10     3        FETCH_DIM_IS                                     ~7      !0, !2
          4        COALESCE                                         ~8      ~7
          5        QM_ASSIGN                                        ~8      0
          6        ADD                                              ~9      ~8, !1
          7        ASSIGN_DIM                                               !0, !2
          8        OP_DATA                                                  ~9
   11     9        ASSIGN                                                   !2, 'bar'
   12    10        FETCH_DIM_IS                                     ~12     !0, !2
         11        COALESCE                                         ~13     ~12
         12        QM_ASSIGN                                        ~13     0
         13        ADD                                              ~14     ~13, !1
         14        ASSIGN_DIM                                               !0, !2
         15        OP_DATA                                                  ~14
   13    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function addorincr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ke0po
function name:  addOrIncr
number of ops:  10
compiled vars:  !0 = $arr, !1 = $key, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        FETCH_DIM_IS                                     ~4      !0, !1
          4        COALESCE                                         ~5      ~4
          5        QM_ASSIGN                                        ~5      0
          6        ADD                                              ~6      ~5, !2
          7        ASSIGN_DIM                                               !0, !1
          8        OP_DATA                                                  ~6
    5     9      > RETURN                                                   null

End of function addorincr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.71 ms | 941 KiB | 16 Q