Ok… this is my first post here, so I'm going to start out relatively small.
While I was working on the update of my flip gallery script today I needed a way to check a variable for a particular string, and if that string didn't appear I wanted to execute any php code that was embedded in the variable (which was the contents of Movable Type's Extended Entry field). Then I wanted to dump the output into a new variable. The eval() function worked perfectly for this:
ob_start();
eval("?>" . $entry_text . "<?php ");
$result_text = ob_get_contents();
ob_end_clean();
ob_start(), ob_get_contents(), and ob_end_clean() are functions that control output buffering. Basically, ob_start() causes php to begin caching output rather than sending it to the browser, ob_get_contents() returns all the cached results, and ob_end_clean() empties the output buffer and turns output buffering off again.
Feel free to check out the Flip Gallery code if you want to see how this works.
The output buffer catches all output, not only script output: