- stream_get_contents: documentation ( source)
- stream_filter_append: documentation ( source)
- fwrite: documentation ( source)
- rewind: documentation ( source)
- fopen: documentation ( source)
<?php
$testString = 'test';
$stream = fopen('php://memory','r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-encode');
echo "memoryStream = " . stream_get_contents($stream).PHP_EOL;