PHP File Maker

This is a simple way to use PHP to generate a file. I used this in several situations where a file download needed to be created dynamically.

<?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.";
?>

Posted on: May 25, 2015