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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.95 ms | 1400 KiB | 15 Q