3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php file_put_contents("test.txt", "Hello, world!"); $handle = fopen("test.txt", "r"); $contents = stream_get_contents($handle); echo "Contents A = {$contents}\n"; $contents = stream_get_contents($handle); echo "Contents B = {$contents}\n"; fclose($handle);
Output for 5.3.0 - 7.1.0
Warning: file_put_contents(test.txt): failed to open stream: Permission denied in /in/gHkPG on line 3 Warning: fopen(test.txt): failed to open stream: No such file or directory in /in/gHkPG on line 5 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/gHkPG on line 6 Contents A = Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/gHkPG on line 9 Contents B = Warning: fclose() expects parameter 1 to be resource, boolean given in /in/gHkPG on line 12
Output for 5.0.0 - 5.2.17
Warning: file_put_contents(test.txt): failed to open stream: Permission denied in /in/gHkPG on line 3 Warning: fopen(test.txt): failed to open stream: No such file or directory in /in/gHkPG on line 5 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/gHkPG on line 6 Contents A = Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/gHkPG on line 9 Contents B = Warning: fclose(): supplied argument is not a valid stream resource in /in/gHkPG on line 12
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: file_put_contents() in /in/gHkPG on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: file_put_contents() in /in/gHkPG on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: file_put_contents() in /in/gHkPG on line 3