Re: How to take output from an include, and embed it into a variable?
| From: | Eddie Drapkin | Date: | Tue, 08 Sep 2009 04:37:06 +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-297783@lists.php.net to get a copy of this message | ||
On Tue, Sep 8, 2009 at 12:35 AM, Rob Gould<gouldimg@mac.com> 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"?
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Use output buffering and capture:
http://us3.php.net/manual/en/book.outcontrol.php
ob_start();
include 'stuff_that_makes_html.php';
$contents = ob_get_clean();