in una pagina metti che ho questo codice:
Codice PHP:
<?php
include_once('config.php');
if(
$forumtype=='smf'){
$new=ssi_boardNews($forum,5);
foreach(
$new as $news);
$com=$news['locked'] ? '' ' | ' $news['comment_link'];
$smarty->assign('href',$news['href']);
$smarty->assign('subject',$news['subject']);
$smarty->assign('time',$news['time']);
$smarty->assign('poster_link',$news['poster']['link']);
$smarty->assign('body',$news['body']);
$smarty->assign('link',$news['link']);
$smarty->assign('com',$com);
} elseif(
$forumtype=='phpBB'){
    
$query[0]=$sql->query('SELECT * FROM '.$prefix.'topics WHERE forum_id ='.$forum.' ORDER BY topic_id ASC LIMIT 0,5',__LINE__,__FILE__);
    while(
$ris[0]=mysql_fetch_array($query[0]) or die(mysql_error())){
        
$query[1]=$sql->query('SELECT * FROM '.$prefix.'users WHERE user_id ='.$ris[0]['topic_poster'],__LINE__,__FILE__);
        
$ris[1]=mysql_fetch_array($query[1]);
        
$smarty->assign('href',$forumurl.'/viewtopic.php?t='.$ris[0]['topic_id']);
        
$smarty->assign('subject',$ris[0]['topic_title']);
        
$smarty->assign('time',date('D d-m-Y H:i',$ris[0]['topic_time']));
        
$smarty->assign('poster_link','[url="'.$forumurl.'profile.php?mode=viewprofile&u='.$ris[0]['topic_poster'].'"]'.$ris[1]['username'].'[/url]');
        
$query[2]=$sql->query('SELECT * FROM '.$prefix.'posts WHERE topic_id='.$ris[0]['topic_id'].' ORDER BY topic_id AND post_id DESC LIMIT 0,1',__LINE__,__FILE__);
        
$ris[2]=mysql_fetch_array($query[2]);
        
$query[3]=$sql->query('SELECT * FROM '.$prefix.'posts_text WHERE post_id='.$ris[2]['post_id'],__LINE__,__FILE__);
        
$ris[3]=mysql_fetch_array($query[3]);
        
$bbcode nl2br($ris[3]['post_text']);
        
$bbcode str_replace("[b(.*?)]""[b]"$bbcode);
        
$bbcode str_replace("[/b(.*?)]""[/b]"$bbcode);
        
$bbcode str_replace("[i(.*?)\]""[i]"$bbcode);
        
$bbcode str_replace("[/i(.*?)]""[/i]"$bbcode);
        
$bbcode str_replace("[u(.*?)\]""<u>"$bbcode);
        
$bbcode str_replace("[/u(.*?)]""</u>"$bbcode);
        
$bbcode str_replace("[quote(.*?)]"'<div id="quote">' $bbcode);
        
$bbcode str_replace("[/quote(.*?)]"'</div>' $bbcode);
        
$bbcode str_replace("[code(.*?)]"'<div id="code">' $bbcode);
        
$bbcode str_replace("[/code(.*?)]"'</div>' $bbcode);
        
$smarty->assign('body',$bbcode);
        
$smarty->assign('link','[url="'.$forumurl.'/viewtopic.php?t='.$ris[0]['topic_id'].'"]vai al topic[/url]');
        
$smarty->assign('com',$ris[0]['topic_replies']);
        
$smarty->assign('siteurl',$siteurl);
        
$smarty->display($themedir.'/page/main.tpl');
    }
}
?>
come vedi questo script usa smarty, che da a vedere un file tpl...
ora così tutto bene, ma metti che volessi mettere il contenuto del file tpl(HTML) in una stringa, come potrei fare?
avete capito ora?
invece di visualizzarlo vorrei mandare in output il codice html eseguito(intendo senza {$smarty} ecc...).