3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = 'Test string for writing and reading from memory stream'; $r = fopen('php://memory', 'rw'); var_dump(fwrite($r, $str)); fseek($r, 0); var_dump(stream_get_contents($r));
based on g3mBM
Output for 5.1.4 - 7.2.0
int(54) string(54) "Test string for writing and reading from memory stream"
Output for 5.0.0 - 5.1.3
Warning: fopen(php://memory): failed to open stream: Success in /in/i0amd on line 3 Warning: fwrite(): supplied argument is not a valid stream resource in /in/i0amd on line 5 bool(false) Warning: fseek(): supplied argument is not a valid stream resource in /in/i0amd on line 6 Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /in/i0amd on line 7 bool(false)
Output for 4.4.5 - 4.4.9
Warning: fopen(php://memory): failed to open stream: Success in /in/i0amd on line 3 Warning: fwrite(): supplied argument is not a valid stream resource in /in/i0amd on line 5 bool(false) Warning: fseek(): supplied argument is not a valid stream resource in /in/i0amd on line 6 Fatal error: Call to undefined function: stream_get_contents() in /in/i0amd on line 7
Process exited with code 255.
Output for 4.3.5 - 4.4.4
Warning: fopen(php://memory): failed to open stream: Success in /in/i0amd on line 3 Warning: fwrite(): supplied argument is not a valid stream resource in /in/i0amd on line 5 bool(false) Warning: fseek(): supplied argument is not a valid stream resource in /in/i0amd on line 6 Fatal error: Call to undefined function: stream_get_contents() in /in/i0amd on line 7
Process exited with code 255.
Output for 4.3.3 - 4.3.4
Warning: fopen(php://memory): failed to open stream: Success in /in/i0amd on line 3 Warning: fwrite(): supplied argument is not a valid stream resource in /in/i0amd on line 5 NULL Warning: fseek(): supplied argument is not a valid stream resource in /in/i0amd on line 6 Fatal error: Call to undefined function: stream_get_contents() in /in/i0amd on line 7
Process exited with code 255.
Output for 4.3.2
Warning: fopen(php://memory): failed to open stream: Inappropriate ioctl for device in /in/i0amd on line 3 Warning: fwrite(): supplied argument is not a valid stream resource in /in/i0amd on line 5 NULL Warning: fseek(): supplied argument is not a valid stream resource in /in/i0amd on line 6 Fatal error: Call to undefined function: stream_get_contents() in /in/i0amd on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: fopen(php://memory) [http://www.php.net/function.fopen]: failed to create stream: Inappropriate ioctl for device in /in/i0amd on line 3 Warning: fwrite(): supplied argument is not a valid stream resource in /in/i0amd on line 5 NULL Warning: fseek(): supplied argument is not a valid stream resource in /in/i0amd on line 6 Fatal error: Call to undefined function: stream_get_contents() in /in/i0amd on line 7