- var_dump: documentation ( source)
- stream_get_contents: documentation ( source)
- fwrite: documentation ( source)
- fopen: documentation ( source)
<?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));