title: Simple PHP hit counter incrementing by two?
body: <p>I made a hit counter for a web app, but am confused as to why it's incrementing by two. I simply set a counter variable from the hitCount.txt file, which contains an integer and write the pre-incremented value back to the file.</p>
  
  <p>The code in question:</p>
  
  <pre><code>    // get visit count
      $wag_file = "hitCount.txt";
      $fh = fopen($wag_file, 'r+');
      $wag_visit_count = intval(file_get_contents($wag_file));
      // increment, rewrite, and display visit count
      fputs($fh, ++$wag_visit_count);
      fclose($fh);
      echo $wag_visit_count . $html_br;
  </code></pre>