RE: PHP 4.0 Bug #8282 Updated: Is there a function for this?

From: Date: Wed, 10 Jan 2001 16:10:06 +0000
Subject: RE: PHP 4.0 Bug #8282 Updated: Is there a function for this?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-43701@lists.php.net to get a copy of this message
> ID: 8282 > Updated by: david > Reported By: cnewbill@onewest.net > Status: Open > Bug Type: Feature/Change Request > Assigned To: > Comments: > > so why don't you have your own I do, just wondering what the possibility of getting that functionality added is, thus the 'Request'. I did not think this would be a difficult change to the source or that it would adversely impact anyone's code. Which seems like pretty good criteria for an addition to me, unless no one else feels that this could be of any use. > 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. Think so, but I haven't run into the situation where I would need to do that...yet. > > Previous Comments: > ------------------------------------------------------------------ > --------- > > [2000-12-15 14:50:32] cnewbill@onewest.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 > > ------------------------------------------------------------------ > --------- > > > Full Bug description available at: http://bugs.php.net/?id=8282 > >

« previous php.dev (#43701) next »