Codice PHP:
<?php

$testo 
"Testo da scaricare";

header('Content-type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-disposition: attachment;
filename=download.txt'
);
echo(
$testo);

?>