title: How to get include contents as a string?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1683771/execute-a-php-file-and-return-the-result-as-a-string">Execute a PHP file, and return the result as a string</a><br>
    <a href="https://stackoverflow.com/questions/4798142/php-capture-print-require-output-in-variable">PHP capture print/require output in variable</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to get the contents of an include to a string. Is that possible?</p>
  
  <p>For example, if I have a test.php file:</p>
  
  <pre><code>echo 'a is equal to '.$a;
  </code></pre>
  
  <p>I need a function, say include_to_string to include the test.php and return what would be output by in in a string.</p>
  
  <p>Something like:</p>
  
  <pre><code>$a = 4;
  $string = include_to_string(test.php); // $string = "a is equal to 4"
  </code></pre>