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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.38 ms | 1008 KiB | 15 Q