3v4l.org

run code in 500+ PHP versions simultaneously
<?php $file = new SplTempFileObject(); for ($i = 0; $i < 100; $i++) { $file->fwrite("Foo $i\n"); } $file->seek(50); $nextBefore = []; while ($file->valid() && $file->key() <= 53) { $file->next(); $line = $file->current(); $nextBefore[$file->key()] = trim($line); } $file->seek(50); $nextAfter = []; while ($file->valid() && $file->key() <= 53) { $line = $file->current(); $nextAfter[$file->key()] = trim($line); $file->next(); } $file->seek(50); $fgets = []; while ($file->valid() && $file->key() <= 53) { $line = $file->fgets(); $fgets[$file->key()] = trim($line); } echo "-- Next Before --\n"; print_r($nextBefore) . PHP_EOL; echo "-- Next After --\n"; print_r($nextAfter) . PHP_EOL; echo "-- fgets --\n"; print_r($fgets) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 19
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 42
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
2 jumps found. (Code = 46) Position 1 = 76, Position 2 = 80
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 81, Position 2 = 65
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
2 jumps found. (Code = 46) Position 1 = 76, Position 2 = 80
Branch analysis from position: 76
Branch analysis from position: 80
Branch analysis from position: 80
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
Branch analysis from position: 59
Branch analysis from position: 59
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
Branch analysis from position: 36
Branch analysis from position: 36
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
filename:       /in/UpN1G
function name:  (null)
number of ops:  100
compiled vars:  !0 = $file, !1 = $i, !2 = $nextBefore, !3 = $line, !4 = $nextAfter, !5 = $fgets
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   NEW                                                  $6      'SplTempFileObject'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $6
    5     3        ASSIGN                                                       !1, 0
          4      > JMP                                                          ->12
    6     5    >   INIT_METHOD_CALL                                             !0, 'fwrite'
          6        ROPE_INIT                                         3  ~11     'Foo+'
          7        ROPE_ADD                                          1  ~11     ~11, !1
          8        ROPE_END                                          2  ~10     ~11, '%0A'
          9        SEND_VAL_EX                                                  ~10
         10        DO_FCALL                                          0          
    5    11        PRE_INC                                                      !1
         12    >   IS_SMALLER                                                   !1, 100
         13      > JMPNZ                                                        ~15, ->5
    9    14    >   INIT_METHOD_CALL                                             !0, 'seek'
         15        SEND_VAL_EX                                                  50
         16        DO_FCALL                                          0          
   11    17        ASSIGN                                                       !2, <array>
   12    18      > JMP                                                          ->29
   13    19    >   INIT_METHOD_CALL                                             !0, 'next'
         20        DO_FCALL                                          0          
   14    21        INIT_METHOD_CALL                                             !0, 'current'
         22        DO_FCALL                                          0  $19     
         23        ASSIGN                                                       !3, $19
   15    24        INIT_METHOD_CALL                                             !0, 'key'
         25        DO_FCALL                                          0  $21     
         26        FRAMELESS_ICALL_1                trim                ~23     !3
         27        ASSIGN_DIM                                                   !2, $21
         28        OP_DATA                                                      ~23
   12    29    >   INIT_METHOD_CALL                                             !0, 'valid'
         30        DO_FCALL                                          0  $24     
         31      > JMPZ_EX                                              ~25     $24, ->36
         32    >   INIT_METHOD_CALL                                             !0, 'key'
         33        DO_FCALL                                          0  $26     
         34        IS_SMALLER_OR_EQUAL                                  ~27     $26, 53
         35        BOOL                                                 ~25     ~27
         36    > > JMPNZ                                                        ~25, ->19
   18    37    >   INIT_METHOD_CALL                                             !0, 'seek'
         38        SEND_VAL_EX                                                  50
         39        DO_FCALL                                          0          
   20    40        ASSIGN                                                       !4, <array>
   21    41      > JMP                                                          ->52
   22    42    >   INIT_METHOD_CALL                                             !0, 'current'
         43        DO_FCALL                                          0  $30     
         44        ASSIGN                                                       !3, $30
   23    45        INIT_METHOD_CALL                                             !0, 'key'
         46        DO_FCALL                                          0  $32     
         47        FRAMELESS_ICALL_1                trim                ~34     !3
         48        ASSIGN_DIM                                                   !4, $32
         49        OP_DATA                                                      ~34
   24    50        INIT_METHOD_CALL                                             !0, 'next'
         51        DO_FCALL                                          0          
   21    52    >   INIT_METHOD_CALL                                             !0, 'valid'
         53        DO_FCALL                                          0  $36     
         54      > JMPZ_EX                                              ~37     $36, ->59
         55    >   INIT_METHOD_CALL                                             !0, 'key'
         56        DO_FCALL                                          0  $38     
         57        IS_SMALLER_OR_EQUAL                                  ~39     $38, 53
         58        BOOL                                                 ~37     ~39
         59    > > JMPNZ                                                        ~37, ->42
   27    60    >   INIT_METHOD_CALL                                             !0, 'seek'
         61        SEND_VAL_EX                                                  50
         62        DO_FCALL                                          0          
   29    63        ASSIGN                                                       !5, <array>
   30    64      > JMP                                                          ->73
   31    65    >   INIT_METHOD_CALL                                             !0, 'fgets'
         66        DO_FCALL                                          0  $42     
         67        ASSIGN                                                       !3, $42
   32    68        INIT_METHOD_CALL                                             !0, 'key'
         69        DO_FCALL                                          0  $44     
         70        FRAMELESS_ICALL_1                trim                ~46     !3
         71        ASSIGN_DIM                                                   !5, $44
         72        OP_DATA                                                      ~46
   30    73    >   INIT_METHOD_CALL                                             !0, 'valid'
         74        DO_FCALL                                          0  $47     
         75      > JMPZ_EX                                              ~48     $47, ->80
         76    >   INIT_METHOD_CALL                                             !0, 'key'
         77        DO_FCALL                                          0  $49     
         78        IS_SMALLER_OR_EQUAL                                  ~50     $49, 53
         79        BOOL                                                 ~48     ~50
         80    > > JMPNZ                                                        ~48, ->65
   36    81    >   ECHO                                                         '--+Next+Before+--%0A'
   37    82        INIT_FCALL                                                   'print_r'
         83        SEND_VAR                                                     !2
         84        DO_ICALL                                             $51     
         85        CONCAT                                               ~52     $51, '%0A'
         86        FREE                                                         ~52
   39    87        ECHO                                                         '--+Next+After+--%0A'
   40    88        INIT_FCALL                                                   'print_r'
         89        SEND_VAR                                                     !4
         90        DO_ICALL                                             $53     
         91        CONCAT                                               ~54     $53, '%0A'
         92        FREE                                                         ~54
   42    93        ECHO                                                         '--+fgets+--%0A'
   43    94        INIT_FCALL                                                   'print_r'
         95        SEND_VAR                                                     !5
         96        DO_ICALL                                             $55     
         97        CONCAT                                               ~56     $55, '%0A'
         98        FREE                                                         ~56
   44    99      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
146 ms | 1506 KiB | 9 Q