note 10151 added to eval

From: Date: Fri, 15 Dec 2000 19:38:47 +0000
Subject: note 10151 added to eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-8764@lists.php.net to get a copy of this message
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, . http://www.php.net/manual/function.eval.php

« previous php.notes (#8764) next »