|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-12-15 14:50 UTC] cnewbill at onewest dot net
I guess this is more of a hack than anything, but I really needed eval()'s code NOT to be displayed right away. So I used ob_start(), ob_get_contents(), and ob_end_clean().
<?php
$stuff = "Hello, ";
ob_start(); // start buffer
eval("print 'World!';"); // execute code
$retval = ob_get_contents(); // return executed code
ob_end_clean(); // delete the buffer
print $stuff.$retval;
?>
This would print "Hello, World!" instead of "World!Hello, ".
Is there a function to do this already?
Thanks,
Chris
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
so why don't you have your own function quiet_eval($code) { ob_start(); eval($code); $retval = ob_get_contents(); ob_end_clean(); return $retval; } as I understand it, zend output buffers can be nested, so no issues with it interfering with existing buffers.