3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = new ArrayObject(range(1,11)); echo 'there are ' . $items->count() . ' total items' . "\r\n"; $itemIterator = $items->getIterator(); $cachingIterator = new CachingIterator($itemIterator); $limitIterator = new LimitIterator($cachingIterator, 0, 10); $i = 0; foreach ($limitIterator as $item) { ++$i; } echo 'first page has ' . $i . ' items' . "\r\n"; var_dump($cachingIterator->hasNext() === $itemIterator->valid());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 32
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/5JtJA
function name:  (null)
number of ops:  46
compiled vars:  !0 = $items, !1 = $itemIterator, !2 = $cachingIterator, !3 = $limitIterator, !4 = $i, !5 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $6      'ArrayObject'
          1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 11
          4        DO_ICALL                                         $7      
          5        SEND_VAR_NO_REF_EX                                       $7
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $6
    5     8        INIT_METHOD_CALL                                         !0, 'count'
          9        DO_FCALL                                      0  $10     
         10        CONCAT                                           ~11     'there+are+', $10
         11        CONCAT                                           ~12     ~11, '+total+items'
         12        CONCAT                                           ~13     ~12, '%0D%0A'
         13        ECHO                                                     ~13
    7    14        INIT_METHOD_CALL                                         !0, 'getIterator'
         15        DO_FCALL                                      0  $14     
         16        ASSIGN                                                   !1, $14
    8    17        NEW                                              $16     'CachingIterator'
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !2, $16
   10    21        NEW                                              $19     'LimitIterator'
         22        SEND_VAR_EX                                              !2
         23        SEND_VAL_EX                                              0
         24        SEND_VAL_EX                                              10
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !3, $19
   12    27        ASSIGN                                                   !4, 0
   13    28      > FE_RESET_R                                       $23     !3, ->32
         29    > > FE_FETCH_R                                               $23, !5, ->32
   14    30    >   PRE_INC                                                  !4
   13    31      > JMP                                                      ->29
         32    >   FE_FREE                                                  $23
   17    33        CONCAT                                           ~25     'first+page+has+', !4
         34        CONCAT                                           ~26     ~25, '+items'
         35        CONCAT                                           ~27     ~26, '%0D%0A'
         36        ECHO                                                     ~27
   19    37        INIT_FCALL                                               'var_dump'
         38        INIT_METHOD_CALL                                         !2, 'hasNext'
         39        DO_FCALL                                      0  $28     
         40        INIT_METHOD_CALL                                         !1, 'valid'
         41        DO_FCALL                                      0  $29     
         42        IS_IDENTICAL                                     ~30     $28, $29
         43        SEND_VAL                                                 ~30
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.79 ms | 1400 KiB | 17 Q