3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.78 ms | 1012 KiB | 13 Q