title: php Object to String
body: <p>I'm trying to teach myself php... so please be kind and bear with me.</p>
  
  <p>I'm trying to follow <a href="http://www.gayadesign.com/diy/caching-external-data-in-php/" rel="nofollow noreferrer">this tutorial</a> on how to cache files... the page I want to cache is HTML only, so I've modified the php to just deal with data. I know the caching part is working, it's when I try to modify the results that I get a "Catchable fatal error: Object of class Caching could not be converted to string" in the str_replace line below.</p>
  
  <p>I've tried using the <a href="http://uk3.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring" rel="nofollow noreferrer">__toString method here</a>, and I've tried using <a href="https://stackoverflow.com/questions/1016271/convert-an-object-to-a-string-in-php">serialize</a>. Is there something I'm missing?</p>
  
  <p>Edit: Oh and I've even tried <a href="https://stackoverflow.com/questions/28098/php-tostring-equivalent">casting operators</a>.</p>
  
  <pre><code> $caching = new Caching( "my.htm", "http://www.page-I-want.com/" );
   $info = new TestClass($caching);
   $info = str_replace( "&lt;img src='/images/up.jpg'&gt;","&lt;div class='up'&gt;&lt;/div&gt;", $info );
  </code></pre>
  
  <p>My var_dump($caching); is as follows:</p>
  
  <pre><code>object(Caching)#1 (2) { ["filePath"]=&gt;  string(9) "cache.htm" ["apiURI"]=&gt;  string(27) "http://www.page-I-want.com/" } 
  </code></pre>
  
  <p>Ok, I see now that the problem is with the caching.php not returning the value to the $caching string. Can anyone check out the link below and help me figure out why it's not working? Thanks!</p>
  
  <p>I just posted my entire caching.php file <a href="http://pastebin.com/m602db3c" rel="nofollow noreferrer">here</a>.</p>