3v4l.org

run code in 300+ PHP versions simultaneously
<?php $limit = 5; function test ($limit, $useLimit) { $arr = [1,2,3,4,5,6,7,8,9,10]; foreach($arr as $key => $node) { if (!$useLimit || $key < $limit) { echo $node; } else { break; } } } echo "No limit:\n"; test($limit, false); echo "\n"; echo "With limit:\n"; test($limit, true);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r2KAe
function name:  (null)
number of ops:  13
compiled vars:  !0 = $limit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 5
   15     1        ECHO                                                     'No+limit%3A%0A'
   16     2        INIT_FCALL                                               'test'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <false>
          5        DO_FCALL                                      0          
   17     6        ECHO                                                     '%0A'
   18     7        ECHO                                                     'With+limit%3A%0A'
   19     8        INIT_FCALL                                               'test'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 <true>
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 15
Branch analysis from position: 15
filename:       /in/r2KAe
function name:  test
number of ops:  17
compiled vars:  !0 = $limit, !1 = $useLimit, !2 = $arr, !3 = $node, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $6      !2, ->15
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->15
          5    >   ASSIGN                                                   !4, ~7
    8     6        BOOL_NOT                                         ~9      !1
          7      > JMPNZ_EX                                         ~9      ~9, ->10
          8    >   IS_SMALLER                                       ~10     !4, !0
          9        BOOL                                             ~9      ~10
         10    > > JMPZ                                                     ~9, ->13
    9    11    >   ECHO                                                     !3
         12      > JMP                                                      ->14
   11    13    > > JMP                                                      ->15
    7    14    > > JMP                                                      ->4
         15    >   FE_FREE                                                  $6
   14    16      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.82 ms | 1403 KiB | 15 Q