title: PHP create text file on server
body: <p>In my php application i want to create a error log in a text format so tried like this its working fine in my local machine </p>
  
  <pre><code>if(!$mail-&gt;Send())
  {
   echo "Message could not be sent. &lt;p&gt;";
   echo "Mailer Error: " . $mail-&gt;ErrorInfo;
   $stringData = "Error Info: ".$mail-&gt;ErrorInfo."\t\t";
   $stringData .= "Email to reciepient \t Regnumber: ".$RegNo." \t  Apllicant Name: ".$ApplicantName." Failed --- end ----";
  
  
   $fp = fopen($_SERVER['DOCUMENT_ROOT']."/lib/email_errorlog.txt","wb");
   fwrite($fp,$stringData);
   fclose($fp);
  
   exit;
    }
  </code></pre>
  
  <p>i have already seen discussion in <a href="https://stackoverflow.com/questions/9265274/php-create-and-save-a-txt-file-to-root-directory">PHP Create and Save a txt file to root directory</a> but its not working for me. The problem is, there is no error is showing but text file is not creating. Need to set any permission on the server? </p>