This php script generates a file to be downloaded without saving the file on server or disk. This script can create any type of file.

Script

$file_name='life.html';
$file_content='Life is beautiful';

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename='.$file_name);
header('Content-Length: ' . strlen($file_content));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
echo $file_content;

Output