title: Warning: flock() expects parameter 1 to be resource, string given
body: <p>I have this very simple program in PHP that does not want to work. It returns the same error as topic for unknown reasons to me.</p>
  
  <pre><code>$file = 'counter.txt';
  $counter = file_get_contents($file);
  if(flock($file, LOCK_EX)){
      $counter += 1;
      echo $counter;
      $write = fopen($file, 'w') or die('Unable');
      fwrite($write, $counter);
      flock($file,LOCK_UN);
  }
  </code></pre>