note 79657 deleted from function.eval by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 19:53:45 +0000 |
| Subject: | note 79657 deleted from function.eval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155288@lists.php.net to get a copy of this message | ||
Note Submitter: Elie B.
----
Nicolas Rainard suggested using ob_get_clean() to get the results, and get back to the rest of your
code. However, I'd like to clarify that your application may or may not already rely on output
buffering mechanisms. In all cases, you should not interfere with the rest of your application
without a strong will (and a good reason) to do so.
Enabling output buffering is fine for small scopes (function wide for instance). In that case,
prefer the following:
<?php
function misc_buffered()
{
ob_start();
eval($misc);
$contents = ob_get_contents();
ob_end_clean(); /* <- that's him: it's ob_start() best friend ! */
}
?>
Don't use ob_get_clean() (or any ob_get_* for that matter) for accessing buffered data without
ensuring that either:
1) You call one of the two available end function afterwise, namely ob_end_clean or ob_end_flush.
2) You intend to use the output buffer after your function. And you know the consequences. If you
don't, please choose (1), it's far easier.
Personal advice: *end* what you *start*. It's like if-endif.
You can find plenty of good advice and documentation on http://fr.php.net/manual/en/ref.outcontrol.php
(your mirror / language may vary)