Include both php/ html files, catch & assign output to a string variable

Submitted by Anonymous (not verified) on Tue, 11/17/2009 - 14:15

I need a small core loader for a small website. I dont want to assing content and use php's echo / print functions in all included sub files. I want to be able to include both html / text files and executable php files. I want to catch raw html output and dynamic output from any included php file. This code below can do what I want. But I am not sure if this is a good solution. Any idea?

flush();
ob_start();
include($your_php_or_html_file);
$content = ob_get_clean(); // output of included file
ob_end_clean();

Maybe include_once is better than include.

Add new comment