title: Using php to write to a log file
body: <p>First of I am very very very very bad with php so sorry for this question
  I have an application in which i would like to log some debug data
  and through my project i make a webrequest to my site storing the information in 
  $msg i then want to write the data to my logfile.log on the site.
  i first used fopen fwrite fclose, but heard that file_put_contents would be better
  especially as i very likely will have several users trying to write to the file at once.
  Here's the code:</p>
  
  <pre><code>$msg = $_GET['w'];
  $logfile= 'logfile.log';
  echo file_put_contents($logfile,$msg, FILE_APPEND | LOCK_EX);
  </code></pre>
  
  <p>But as you might guess the code does nothing for me
  i got it working with fopen fwrite fclose
  but i wanted to add each user to a new line.</p>
  
  <p>If any smart brain out there would help me I would appreciate it a ton.</p>
  
  <p>Regards.</p>
  
  <p>EDIT:
  @Jay
  This is how i tried applying it (opening php on the first line)
  EDIT: removed 'tag' from code due to a copy/paste error. </p>
  
  <pre><code>error_reporting(E_ALL); ini_set('display_errors', 1)
  $msg = $_GET['w'];
  $logfile= 'logfile.log';
  echo file_put_contents($logfile,$msg, FILE_APPEND | LOCK_EX);
  </code></pre>