Re: How to take output from an include, and embed it into a variable?
| From: | Puiu Hrenciuc | Date: | Wed, 23 Sep 2009 10:35:42 +0000 |
| Subject: | Re: How to take output from an include, and embed it into a variable? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298268@lists.php.net to get a copy of this message | ||
Hi,
The simplest way (actually the single way I know :) ) would be to
capture the output using output buffering functions, something like this:
// start output buffering
ob_start();
// include the file that generates the HTML (or whatever content)
include "....";
// get output buffer content
$output=ob_get_contents();
// clean output buffer and stop buffering
ob_end_clean();
// the content generated in the included file is now in $output variable
// use it as you consider fit
.........
Regards,
Puiu
Rob Gould wrote:
I have an invoice table that is drawn on a number of pages, so I have all the logic in an include-file like this: include "invoicetable_bottom.php"; However, now I'm needing to take the output from that include file and pass it as an email. To do that, I need to somehow take the output from this include file and get it into a variable somehow. Is there a simple way to do this? Something like: $emailtcontent = include "invoicetable_bottom.php"?