3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $handle = fopen('file', 'w+'); // truncate + attempt to create fwrite($handle, '12345'); // file position > 0 rewind($handle); // position = 0 $content = stream_get_contents($handle); // file position = 0 in PHP 5.1.6, file position > 0 in PHP 5.2.17! fwrite($handle, '6789'); fclose($handle);
Output for 5.3.0 - 7.1.0
Warning: fopen(file): failed to open stream: Permission denied in /in/jGpu6 on line 2 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 3 Warning: rewind() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 4 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 5 Warning: fwrite() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 6 Warning: fclose() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 7
Output for 5.2.3 - 5.2.17
Warning: fopen(file): failed to open stream: Permission denied in /in/jGpu6 on line 2 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 3 Warning: rewind(): supplied argument is not a valid stream resource in /in/jGpu6 on line 4 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 5 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 6 Warning: fclose(): supplied argument is not a valid stream resource in /in/jGpu6 on line 7
Output for 5.0.0 - 5.2.2
Warning: fopen(file): failed to open stream: Read-only file system in /in/jGpu6 on line 2 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 3 Warning: rewind(): supplied argument is not a valid stream resource in /in/jGpu6 on line 4 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/jGpu6 on line 5 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 6 Warning: fclose(): supplied argument is not a valid stream resource in /in/jGpu6 on line 7
Output for 4.4.5 - 4.4.9
Warning: fopen(file): failed to open stream: Read-only file system in /in/jGpu6 on line 2 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 3 Warning: rewind(): supplied argument is not a valid stream resource in /in/jGpu6 on line 4 Fatal error: Call to undefined function: stream_get_contents() in /in/jGpu6 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Warning: fopen(file): failed to open stream: Read-only file system in /in/jGpu6 on line 2 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 3 Warning: rewind(): supplied argument is not a valid stream resource in /in/jGpu6 on line 4 Fatal error: Call to undefined function: stream_get_contents() in /in/jGpu6 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: fopen(file) [http://www.php.net/function.fopen]: failed to create stream: Read-only file system in /in/jGpu6 on line 2 Warning: fwrite(): supplied argument is not a valid stream resource in /in/jGpu6 on line 3 Warning: rewind(): supplied argument is not a valid stream resource in /in/jGpu6 on line 4 Fatal error: Call to undefined function: stream_get_contents() in /in/jGpu6 on line 5