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>
Output for git.master, git.master_jit
<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> Warning: fopen(): open_basedir restriction in effect. File(textfile.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/094ca on line 16 Warning: fopen(textfile.txt): Failed to open stream: Operation not permitted in /in/094ca on line 16 Warning: Undefined array key "textblock" in /in/094ca on line 19 Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, bool given in /in/094ca:19 Stack trace: #0 /in/094ca(19): fwrite(false, NULL) #1 {main} thrown in /in/094ca on line 19
Process exited with code 255.
Output for rfc.property-hooks
<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> Warning: fopen(): open_basedir restriction in effect. File(textfile.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/094ca on line 16 Warning: fopen(textfile.txt): Failed to open stream: Operation not permitted in /in/094ca on line 16 Warning: Undefined array key "textblock" in /in/094ca on line 19 Fatal error: Uncaught TypeError: fwrite(): Argument #1 ($stream) must be of type resource, false given in /in/094ca:19 Stack trace: #0 /in/094ca(19): fwrite(false, NULL) #1 {main} thrown in /in/094ca on line 19
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
73.21 ms | 402 KiB | 8 Q