note 79657 added to function.eval
| From: | ElieB dot at osu1 dot php dot net | Date: | Thu, 06 Dec 2007 23:27:58 +0000 |
| Subject: | note 79657 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132911@lists.php.net to get a copy of this message | ||
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)
----
Server IP: 217.174.196.197
Probable Submitter: 82.225.202.86
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- https://master.php.net/note/edit/79657
Del: integrated -- https://master.php.net/note/delete/79657/integrated
Del: useless -- https://master.php.net/note/delete/79657/useless
Del: bad code -- https://master.php.net/note/delete/79657/bad+code
Del: spam -- https://master.php.net/note/delete/79657/spam
Del: non-english -- https://master.php.net/note/delete/79657/non-english
Del: in docs -- https://master.php.net/note/delete/79657/in+docs
Del: other reasons-- https://master.php.net/note/delete/79657
Reject -- https://master.php.net/note/reject/79657
Search -- https://master.php.net/manage/user-notes.php