title: file_put_contents - blank file?
body: <p>The below script returns the facebook likes of a page in plaintext. I want to save this to a text file so i've added in the file_put_contents below. Its creating the textfile ok but is empty. When run without trying to save a file it works ok and displays the likes. Also other file_put_contents scripts i have running are working ok so not a permissions issue</p>
  
  <pre><code>&lt;?php
    $page_id = "pageidhere";
    $xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&amp;query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
    $fans = $xml-&gt;page-&gt;fan_count;
    $file = 'facebooklikes.txt';
    file_put_contents($file, $fans);  
  ?&gt;
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Edit:</p>
  
  <p>Tried this:</p>
  
  <pre><code>&lt;?php
    $page_id = "pageidhere";
    $xml = simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&amp;query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
    $fans = $xml-&gt;page-&gt;fan_count;
    echo $fans;
    $file = 'facebooklikes.txt';
    file_put_contents($file, $fans);  
  ?&gt;
  </code></pre>
  
  <p>This shows the like count correctly but still doesn't add to the .txt file</p>
  
  <p>Solved:</p>
  
  <p>Thanks Jack</p>
  
  <pre><code>&lt;?php
    $page_id = "pageidhere";
    $xml = simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&amp;query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
    $fans = $xml-&gt;page-&gt;fan_count;
    echo $fans;
    $file = 'facebooklikes.txt';
    file_put_contents($file, (string)$fans);  
  ?&gt;
  </code></pre>