PHP Force Download

We used to just link to a file to download it, for example to let users download, you just link to it: ...
But the problem is, what if you want to let user download a html file or maybe php file without executing it ? I mean if you link to file.html it will just load it, and not download and save it, so how to do that ?

the answer is very easy, for example mypage.html, you want to let visitors download it, so do the following:

The php code:

$file = 'file.php'; // Her choose any file !
if (file_exists(
header('Content-disposition: attachment; filename="' . $file . '"');
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. filesize(
header('Pragma: no-cache');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
$errorfile = 'the file "' . $file ;