title: file_put_contents php permissions
body: <p>This is a question about my system configuration and how apache/php can be affected by that. Code that was working on my dev server failed to work when I moved to production and here is the problem I boiled the error down to. I want to use file_put_contents in php to simply make a file on my system.  Here is the very simple code I am using:</p>
  
  <pre><code>print file_put_contents("testfile.txt","this is my test")?"made file":"failed";
  </code></pre>
  
  <p>No errors are thrown but it always prints "failed". When I run it in the normal directory no file is made but when I move it to a directory with 777 permission, it will make the file <em>but still print "failed" and save nothing into it</em>.  If I change the php file itself to have 777 permission nothing changes. If I change the target file (testtext.txt) to have 777 permission nothing changes.</p>
  
  <p>The when I change the owner of the php file to be the same as the created testfile.txt nothing changes. When I try relative vs. absolute paths nothing changes. For some reason I can have php make the file but it is always empty and using file_put_contents I can't write anything in.</p>
  
  <p>The created file is in the owner and group of 'www-data' while I am acting as root if that helps.  What can I do to get this working?  I think that my version of php is using the suhosin extension if this could have anything to do with it (or if you think there is a way to fix this in php or suhosin ini files I can do that too).</p>
  
  <p>I've been hunting this for hours the last few days.</p>
  
  <p>EDIT: updates based on the comments below.  When I run it in CLI mode <strong>it does work</strong> but since I need to run it through apache how can I use this fact? Does this tell us something about where or what is stopping the file writing?  Also the file_put_contents call is actually returning "false" and not zero. </p>