How can I capture the contents of an included file?

Usually, when you include a file in Php, any output generated by that script is printed out directly.  However, if you'd like to capture it, say for sending an email message, you can do it like so:



ob_start();
include("filename.php");
$message = ob_get_contents();
ob_end_clean();

$message now contains the output from the included file.  You can send it in an email, or whatever!