3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); const LINES = 5; const INDEX = 10; $file = new SplFileObject('/tmp/test.txt', 'w+'); // write to files for ($i = 0; $i < LINES; $i++) { $file->fwrite("line {$i}" . PHP_EOL); } // behaviour of next() $file->rewind(); for ($i = 0; $i < INDEX; $file->next(), $i++); echo 'next(): ', $file->key(), PHP_EOL; // behaviour of seek() $file->rewind(); $file->seek(INDEX); echo 'seek(): ', $file->key(), PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 23
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 9
Branch analysis from position: 19
Branch analysis from position: 9
filename:       /in/5dYAL
function name:  (null)
number of ops:  46
compiled vars:  !0 = $file, !1 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CONST                                                'LINES', 5
    6     1        DECLARE_CONST                                                'INDEX', 10
    8     2        NEW                                                  $2      'SplFileObject'
          3        SEND_VAL_EX                                                  '%2Ftmp%2Ftest.txt'
          4        SEND_VAL_EX                                                  'w%2B'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !0, $2
   11     7        ASSIGN                                                       !1, 0
          8      > JMP                                                          ->16
   12     9    >   INIT_METHOD_CALL                                             !0, 'fwrite'
         10        NOP                                                          
         11        FAST_CONCAT                                          ~6      'line+', !1
         12        CONCAT                                               ~7      ~6, '%0A'
         13        SEND_VAL_EX                                                  ~7
         14        DO_FCALL                                          0          
   11    15        PRE_INC                                                      !1
         16    >   FETCH_CONSTANT                                       ~10     'LINES'
         17        IS_SMALLER                                                   !1, ~10
         18      > JMPNZ                                                        ~11, ->9
   16    19    >   INIT_METHOD_CALL                                             !0, 'rewind'
         20        DO_FCALL                                          0          
   17    21        ASSIGN                                                       !1, 0
         22      > JMP                                                          ->26
         23    >   INIT_METHOD_CALL                                             !0, 'next'
         24        DO_FCALL                                          0          
         25        PRE_INC                                                      !1
         26    >   FETCH_CONSTANT                                       ~16     'INDEX'
         27        IS_SMALLER                                                   !1, ~16
         28      > JMPNZ                                                        ~17, ->23
   18    29    >   ECHO                                                         'next%28%29%3A+'
         30        INIT_METHOD_CALL                                             !0, 'key'
         31        DO_FCALL                                          0  $18     
         32        ECHO                                                         $18
         33        ECHO                                                         '%0A'
   21    34        INIT_METHOD_CALL                                             !0, 'rewind'
         35        DO_FCALL                                          0          
   22    36        INIT_METHOD_CALL                                             !0, 'seek'
         37        FETCH_CONSTANT                                       ~20     'INDEX'
         38        SEND_VAL_EX                                                  ~20
         39        DO_FCALL                                          0          
   23    40        ECHO                                                         'seek%28%29%3A+'
         41        INIT_METHOD_CALL                                             !0, 'key'
         42        DO_FCALL                                          0  $22     
         43        ECHO                                                         $22
         44        ECHO                                                         '%0A'
   24    45      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.6 ms | 1856 KiB | 13 Q