I've got a php function to get info from my database. Once they visit http://example.com/test/download

I wish to produce a fake test.txt (text is dynamic) and download it. It's contents ought to be the same as performing foreach(databaseContent() as $content) { echo $content . '<br/>' } within it.

How do i get began about this? (Using php)

You are able to connect to a php document along wrinkles, which forces a download of type plain text. (Well, indicates towards the browser that which should happen, anyway.)

<?php
header('Content-disposition: attachment; filename=gen.txt');
header('Content-type: text/plain');


echo "this is the file\n";
echo " you could generate content here, instead.";
?>

Obviously, pass in appropriate publish or get args, to manage it wish.