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

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.5 ms | 1493 KiB | 9 Q