title: Saving variable value in a text file using PHP
body: <p>by clicking on a button I am setting a variable in php using Ajax.</p>
  
  <pre><code>submitInfo(var1);
  
  function submitInfo(var1)
  {
    $.ajax({
          type: "POST",
          url: "js/info.php", 
          data: {Info:var1},
          success: function (result) 
          {
               alert(result);
          }
      });
  }
  </code></pre>
  
  <p>in my php code, How can I save "var1" in a text file? I have used this to save variable in a text file but it is not saving anything there:</p>
  
  <pre><code>&lt;?php
  if (isset($_POST['var1'])) 
          {
              echo $_POST['var1'];
          } 
  $file = fopen("js/test.txt","w");
  echo fwrite($file,$var1);
  fclose($file);
  ?&gt;
  </code></pre>