title: When file_put_contents fails if the directory is full, a file with size 0 is created. How to avoid that?
body: <p>When the tmp directory is full, file_put_contents returns FALSE but the file is created with size of 0. file_put_contents should either complete the creation of the file or have no effect at all. For example:</p>
  
  <pre><code>$data = 'somedata';
  $temp_name = '/tmp/myfile';
  if (file_put_contents($temp_name, $data) === FALSE) {
      // the message print that the file could not be created.
      print 'The file could not be created.';
  }
  </code></pre>
  
  <p>But when I go to the tmp directory, I can find the file "myfile" created in the directory with size 0. This makes it difficult to maintain. The file should not be created and I would like to see a message or warning the the tmp directory is full. Am I missing anything? And is this normal behaviors?</p>