3v4l.org

run code in 300+ 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 = 31
Branch analysis from position: 31
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 19
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 46) Position 1 = 59, Position 2 = 63
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 44
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
2 jumps found. (Code = 46) Position 1 = 82, Position 2 = 86
Branch analysis from position: 82
2 jumps found. (Code = 44) Position 1 = 87, Position 2 = 69
Branch analysis from position: 87
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
2 jumps found. (Code = 46) Position 1 = 82, Position 2 = 86
Branch analysis from position: 82
Branch analysis from position: 86
Branch analysis from position: 86
Branch analysis from position: 44
2 jumps found. (Code = 46) Position 1 = 59, Position 2 = 63
Branch analysis from position: 59
Branch analysis from position: 63
Branch analysis from position: 63
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
Branch analysis from position: 38
Branch analysis from position: 38
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:  106
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                                                      ->31
   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        INIT_FCALL                                               'trim'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $23     
         29        ASSIGN_DIM                                               !2, $21
         30        OP_DATA                                                  $23
   12    31    >   INIT_METHOD_CALL                                         !0, 'valid'
         32        DO_FCALL                                      0  $24     
         33      > JMPZ_EX                                          ~25     $24, ->38
         34    >   INIT_METHOD_CALL                                         !0, 'key'
         35        DO_FCALL                                      0  $26     
         36        IS_SMALLER_OR_EQUAL                              ~27     $26, 53
         37        BOOL                                             ~25     ~27
         38    > > JMPNZ                                                    ~25, ->19
   18    39    >   INIT_METHOD_CALL                                         !0, 'seek'
         40        SEND_VAL_EX                                              50
         41        DO_FCALL                                      0          
   20    42        ASSIGN                                                   !4, <array>
   21    43      > JMP                                                      ->56
   22    44    >   INIT_METHOD_CALL                                         !0, 'current'
         45        DO_FCALL                                      0  $30     
         46        ASSIGN                                                   !3, $30
   23    47        INIT_METHOD_CALL                                         !0, 'key'
         48        DO_FCALL                                      0  $32     
         49        INIT_FCALL                                               'trim'
         50        SEND_VAR                                                 !3
         51        DO_ICALL                                         $34     
         52        ASSIGN_DIM                                               !4, $32
         53        OP_DATA                                                  $34
   24    54        INIT_METHOD_CALL                                         !0, 'next'
         55        DO_FCALL                                      0          
   21    56    >   INIT_METHOD_CALL                                         !0, 'valid'
         57        DO_FCALL                                      0  $36     
         58      > JMPZ_EX                                          ~37     $36, ->63
         59    >   INIT_METHOD_CALL                                         !0, 'key'
         60        DO_FCALL                                      0  $38     
         61        IS_SMALLER_OR_EQUAL                              ~39     $38, 53
         62        BOOL                                             ~37     ~39
         63    > > JMPNZ                                                    ~37, ->44
   27    64    >   INIT_METHOD_CALL                                         !0, 'seek'
         65        SEND_VAL_EX                                              50
         66        DO_FCALL                                      0          
   29    67        ASSIGN                                                   !5, <array>
   30    68      > JMP                                                      ->79
   31    69    >   INIT_METHOD_CALL                                         !0, 'fgets'
         70        DO_FCALL                                      0  $42     
         71        ASSIGN                                                   !3, $42
   32    72        INIT_METHOD_CALL                                         !0, 'key'
         73        DO_FCALL                                      0  $44     
         74        INIT_FCALL                                               'trim'
         75        SEND_VAR                                                 !3
         76        DO_ICALL                                         $46     
         77        ASSIGN_DIM                                               !5, $44
         78        OP_DATA                                                  $46
   30    79    >   INIT_METHOD_CALL                                         !0, 'valid'
         80        DO_FCALL                                      0  $47     
         81      > JMPZ_EX                                          ~48     $47, ->86
         82    >   INIT_METHOD_CALL                                         !0, 'key'
         83        DO_FCALL                                      0  $49     
         84        IS_SMALLER_OR_EQUAL                              ~50     $49, 53
         85        BOOL                                             ~48     ~50
         86    > > JMPNZ                                                    ~48, ->69
   36    87    >   ECHO                                                     '--+Next+Before+--%0A'
   37    88        INIT_FCALL                                               'print_r'
         89        SEND_VAR                                                 !2
         90        DO_ICALL                                         $51     
         91        CONCAT                                           ~52     $51, '%0A'
         92        FREE                                                     ~52
   39    93        ECHO                                                     '--+Next+After+--%0A'
   40    94        INIT_FCALL                                               'print_r'
         95        SEND_VAR                                                 !4
         96        DO_ICALL                                         $53     
         97        CONCAT                                           ~54     $53, '%0A'
         98        FREE                                                     ~54
   42    99        ECHO                                                     '--+fgets+--%0A'
   43   100        INIT_FCALL                                               'print_r'
        101        SEND_VAR                                                 !5
        102        DO_ICALL                                         $55     
        103        CONCAT                                           ~56     $55, '%0A'
        104        FREE                                                     ~56
   44   105      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.57 ms | 1409 KiB | 17 Q