3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['one', 'two', 'three', 'four', 'five']; echo 'Current value: ' . current($arr) . "\n"; foreach ($arr as $a) { if ($a === 'three') break; } echo 'Did it change? ' . current($arr) . "\n"; function withRef(array &$arr): void { foreach ($arr as $a) { if ($a === 'three') break; } } withRef($arr); echo 'What about now? ' . current($arr) . "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 13
Branch analysis from position: 13
filename:       /in/LAbQA
function name:  (null)
number of ops:  30
compiled vars:  !0 = $arr, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'current'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        CONCAT                                           ~4      'Current+value%3A+', $3
          5        CONCAT                                           ~5      ~4, '%0A'
          6        ECHO                                                     ~5
    7     7      > FE_RESET_R                                       $6      !0, ->13
          8    > > FE_FETCH_R                                               $6, !1, ->13
    9     9    >   IS_IDENTICAL                                             !1, 'three'
         10      > JMPZ                                                     ~7, ->12
         11    > > JMP                                                      ->13
    7    12    > > JMP                                                      ->8
         13    >   FE_FREE                                                  $6
   12    14        INIT_FCALL                                               'current'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $8      
         17        CONCAT                                           ~9      'Did+it+change%3F+', $8
         18        CONCAT                                           ~10     ~9, '%0A'
         19        ECHO                                                     ~10
   22    20        INIT_FCALL                                               'withref'
         21        SEND_REF                                                 !0
         22        DO_FCALL                                      0          
   24    23        INIT_FCALL                                               'current'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $12     
         26        CONCAT                                           ~13     'What+about+now%3F+', $12
         27        CONCAT                                           ~14     ~13, '%0A'
         28        ECHO                                                     ~14
         29      > RETURN                                                   1

Function withref:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 7
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
Branch analysis from position: 7
filename:       /in/LAbQA
function name:  withRef
number of ops:  9
compiled vars:  !0 = $arr, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1      > FE_RESET_R                                       $2      !0, ->7
          2    > > FE_FETCH_R                                               $2, !1, ->7
   18     3    >   IS_IDENTICAL                                             !1, 'three'
          4      > JMPZ                                                     ~3, ->6
          5    > > JMP                                                      ->7
   16     6    > > JMP                                                      ->2
          7    >   FE_FREE                                                  $2
   20     8      > RETURN                                                   null

End of function withref

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.36 ms | 1440 KiB | 15 Q