I used this snippet to dynamically create some content and allow the user to download it as a file.
$fileContent = ".... Your Content ..."; $filename = "licenseFile.lic"; header("Content-Type: application/download"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); header("Content-Disposition: attachment; filename=\"$filename\""); echo $fileContent; exit()