note 29271 deleted from function.ob-get-contents by nlopess

From: Date: Sun, 25 Jan 2004 16:26:47 +0000
Subject: note 29271 deleted from function.ob-get-contents by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64156@lists.php.net to get a copy of this message
Note Submitter: shadedecho ---- 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!

« previous php.notes (#64156) next »