title: PHP converting object to string
body: <p>I'm planning to save a returned object to a file, for downloading later on to review.
  For clarity sake, I'm working with an outside API service, and gathering their data, for parsing into another database.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>&lt;?php
  require('class.php');
  $client = new connect2Them();
  $logged_in = $client-&gt;login();
  if(!$logged_in){
    echo "Not connected!"; die();
  }
  
  $records = $client-&gt;get_records();
  if(count($records &lt; 1){
    echo "No records found"; die();
  }
  
  $singlerecord = $records[0];
  print_r($singlerecord);
  
  ?&gt;
  </code></pre>
  
  <p>The print_r() works fine, and I get back a very very large amount of data.  I'm doing all this via command-line, so I want to save it to a text file.</p>
  
  <p>I've added this below my $singlerecord:</p>
  
  <pre><code>&lt;?php
  $myFile = "reviewLater.txt";
  $fh = fopen($myFile, 'w') or die("can't open file");
  $stringData = $singlerecord;
  fwrite($fh, $stringData);
  fclose($fh);
  
  ?&gt;
  </code></pre>
  
  <p>I get this error from PHP:
  <strong>PHP Warning:  fwrite() expects parameter 2 to be string, object given in....</strong></p>
  
  <p>How do I put the print_r() into the reviewLater.txt?</p>