- stream_get_contents: documentation ( source)
- rewind: documentation ( source)
- fputs: documentation ( source)
- fopen: documentation ( source)
<?php
// Установка предела в 5 MB.
$fiveMBs = 5 * 1024 * 1024;
$fp = fopen("php://temp", 'r+');
fputs($fp, "hello\n");
// Читаем то, что мы записали.
rewind($fp);
echo stream_get_contents($fp);