- tempnam: documentation ( source)
- base64_encode: documentation ( source)
- fwrite: documentation ( source)
- fread: documentation ( source)
- fopen: documentation ( source)
<?php
$file = '/dev/urandom';
$handle = fopen($file, 'r');
$files = array();
while ( TRUE )
{
$data = base64_encode(fread($handle, 200));
$tmp = fopen(tempnam(), 'r');
fwrite($tmp, 'hello');
// Store the file pointer so that it isn't freed
// right away.
$files[] = $tmp;
}