note 29271 added to function.ob-get-contents
| From: | shadedecho at rack1 dot php dot net | Date: | Fri, 07 Feb 2003 19:48:06 +0000 |
| Subject: | note 29271 added to function.ob-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43583@lists.php.net to get a copy of this message | ||
When I originally learned PHP a few years ago, I actually thought to myself how UN-useful these
functions probably were in real applications. Boy was I wrong.
I just wanted to mention that I found a very useful application of these functions in a project for
work. Maybe this example will help spur someone's thought process and find an application of
them in their project.
I'm writing an intranet application which basically is a web-based timesheet system. One of the
functions I wrote (about 900 lines of code) breaks in and out of PHP blocks while outputing HTML and
making all kinds of database calls and calls to OO functions, all just to create a nice pretty
visual representation of the timesheet. The need has arisen to also send a HTML version of a
particular timesheet via email to a user. I did not at all want to rewrite this functionality again
JUST to send the data to a variable as opposed to the screen. a simple call to ob_start() before
calling the function, then a $blah = ob_get_contents(), and boom, I had the HTML output from this
complicated function in a variable that could easily be sent to the mail() function for emailing!
PHP never ceases to amaze me!
--
http://www.php.net/manual/en/function.ob-get-contents.php
http://master.php.net/manage/user-notes.php?action=edit+29271
http://master.php.net/manage/user-notes.php?action=delete+29271
http://master.php.net/manage/user-notes.php?action=reject+29271