30 January 2009

Include a file and store contents to variable using output buffer

ob_start(); // start buffer
include ("file-to-include.php");
$content = ob_get_contents(); // assign buffer contents to variable
ob_end_clean(); // end buffer and remove buffer contents
echo $content;

No comments: