3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fp = fopen('/tmp/test.txt', 'a+'); fwrite($fp, 'foo'); echo ftell($fp) ."\n"; fseek($fp, 0); fwrite($fp, 'bar'); echo ftell($fp) ."\n"; echo fread($fp, 3) ."\n"; fseek($fp, 0); echo fread($fp, 6) ."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mvTmZ
function name:  (null)
number of ops:  44
compiled vars:  !0 = $fp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'fopen'
          1        SEND_VAL                                                 '%2Ftmp%2Ftest.txt'
          2        SEND_VAL                                                 'a%2B'
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
    4     5        INIT_FCALL                                               'fwrite'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 'foo'
          8        DO_ICALL                                                 
    5     9        INIT_FCALL                                               'ftell'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $4      
         12        CONCAT                                           ~5      $4, '%0A'
         13        ECHO                                                     ~5
    6    14        INIT_FCALL                                               'fseek'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 0
         17        DO_ICALL                                                 
    7    18        INIT_FCALL                                               'fwrite'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 'bar'
         21        DO_ICALL                                                 
    8    22        INIT_FCALL                                               'ftell'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $8      
         25        CONCAT                                           ~9      $8, '%0A'
         26        ECHO                                                     ~9
    9    27        INIT_FCALL                                               'fread'
         28        SEND_VAR                                                 !0
         29        SEND_VAL                                                 3
         30        DO_ICALL                                         $10     
         31        CONCAT                                           ~11     $10, '%0A'
         32        ECHO                                                     ~11
   10    33        INIT_FCALL                                               'fseek'
         34        SEND_VAR                                                 !0
         35        SEND_VAL                                                 0
         36        DO_ICALL                                                 
   11    37        INIT_FCALL                                               'fread'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 6
         40        DO_ICALL                                         $13     
         41        CONCAT                                           ~14     $13, '%0A'
         42        ECHO                                                     ~14
         43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.07 ms | 1401 KiB | 23 Q