Sasuun Posted March 5, 2006 Share Posted March 5, 2006 I'm using eval to execute php I have stored in a mysql database for a blocks system, but in order to aviod any problems using function such as header() or session_start() after output has been sent, I store all of my output in a variable $OUTPUT and on the last line of my script echo that var. This was all going fine until I added a php filter to my block system, which worked great, except my output would always be printed above everything else on my site, so I went to php.net and read up on the eval() function, and lo and behold I finally realized they had a tip for using eval[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Tip: As with anything that outputs its result directly to the browser, you can use the output-control functions to capture the output of this function, and save it in a string (for example).[/quote]I have no idea how to use output-control functions, and I've been reading about them searching for a couple of hours with no luck Does anyone know how I could capture the output and put it in my $OUTPUT var?incase it helps, here is my get_blocks function[code]function get_blocks($position) { $ACHTML = ''; #initialize variable and make sure it doesn't have any data in it $sql = "SELECT * FROM ac_blocks WHERE `position` = '$position' ORDER BY `order` ASC"; $get = mysql_query($sql) or die(mysql_error()); while ($blocks = mysql_fetch_array($get)) { if ($position == "C") { $ACHTML .= site_box($blocks['block_title']); }else { $ACHTML .= make_menu($blocks['block_title']); } if ($blocks['filter_method'] == 0)#bbcode { $ACHTML .= $this->bbcode2html($blocks['content'],'1'); } elseif ($blocks['filter_method'] == 1)#we're parsing raw php { $ACHTML .= eval($blocks['content']); }else { $ACHTML .= "block error"; } $ACHTML .= close_menu(); } return $ACHTML; }[/code] Quote Link to comment Share on other sites More sharing options...
Sasuun Posted March 5, 2006 Author Share Posted March 5, 2006 so... anyone feel like tackling this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.