title: Converting a PHP file into a txt file
body: <p>I have a php file which takes in data from my SQL database and stores it into a table. I need to create a button which when the user clicks the button it will save that whole page into a .txt file </p>
  
  <p>I have try to use this code </p>
  
  <pre><code>&lt;?php $html = file_get_contents('test.php');
  
    file_put_contents("test.txt","$html");?&gt;
  </code></pre>
  
  <p>But it saves the php code without the data from the database. I assume it does this because it is reading in the file test.php not the web page it creates. </p>
  
  <p>So my question is how can i get it to save the web page it creates with all the data form the SQL database form a button click?</p>