title: Forcing to download a file using PHP
body: <p>I have a CSV file on my server. If a user clicks on a link it should download, but instead it opens up in my browser window.</p>
  
  <p>My code looks as follows</p>
  
  <pre><code>&lt;a href="files/csv/example/example.csv"&gt;
      Click here to download an example of the "CSV" file
  &lt;/a&gt;
  </code></pre>
  
  <p>It's a normal webserver where I have all of my development work on.</p>
  
  <p>I tried something like:</p>
  
  <pre><code>&lt;a href="files/csv/example/csv.php"&gt;
      Click here to download an example of the "CSV" file
  &lt;/a&gt;
  </code></pre>
  
  <p>Now the contents of my <code>csv.php</code> file:</p>
  
  <pre><code>header('Content-Type: application/csv');
  header('Content-Disposition: attachment; filename=example.csv');
  header('Pragma: no-cache');
  </code></pre>
  
  <p>Now my issue is it's downloading, but not my CSV file. It creates a new file.</p>