3v4l.org

run code in 300+ PHP versions simultaneously
<html> <head> <title>Write to a text file</title> </head> <body> <h1>Adding a text block to a text file:</h1> <form action="myfile.php" method='post'> <textarea name='textblock'></textarea> <input type='submit' value='Add text'> </form> <?php // Open the text file $f = fopen("textfile.txt", "w"); // Write text fwrite($f, $_POST["textblock"]); // Close the text file fclose($f); // Open file for reading, and read the line $f = fopen("textfile.txt", "r"); // Read text echo fgets($f); fclose($f); ?> </body> </html>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/094ca
function name:  (null)
number of ops:  29
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3Chtml%3E%0A%09%3Chead%3E%0A%09%3Ctitle%3EWrite+to+a+text+file%3C%2Ftitle%3E%0A%09%3C%2Fhead%3E%0A%09%3Cbody%3E%0A%0A%09%3Ch1%3EAdding+a+text+block+to+a+text+file%3A%3C%2Fh1%3E%0A%09%3Cform+action%3D%22myfile.php%22+method%3D%27post%27%3E%0A%09%3Ctextarea+name%3D%27textblock%27%3E%3C%2Ftextarea%3E%0A%09%3Cinput+type%3D%27submit%27+value%3D%27Add+text%27%3E%0A%09%3C%2Fform%3E%0A%0A%09'
   16     1        INIT_FCALL                                               'fopen'
          2        SEND_VAL                                                 'textfile.txt'
          3        SEND_VAL                                                 'w'
          4        DO_ICALL                                         $1      
          5        ASSIGN                                                   !0, $1
   19     6        INIT_FCALL                                               'fwrite'
          7        SEND_VAR                                                 !0
          8        FETCH_R                      global              ~3      '_POST'
          9        FETCH_DIM_R                                      ~4      ~3, 'textblock'
         10        SEND_VAL                                                 ~4
         11        DO_ICALL                                                 
   22    12        INIT_FCALL                                               'fclose'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   25    15        INIT_FCALL                                               'fopen'
         16        SEND_VAL                                                 'textfile.txt'
         17        SEND_VAL                                                 'r'
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !0, $7
   28    20        INIT_FCALL                                               'fgets'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $9      
         23        ECHO                                                     $9
   29    24        INIT_FCALL                                               'fclose'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                                 
   32    27        ECHO                                                     '%09%0A%09%3C%2Fbody%3E%0A%0A%09%3C%2Fhtml%3E'
   35    28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
191.52 ms | 1388 KiB | 21 Q