i have a function that passes arrays of objects to a template file, and that template file has details from php arrays/objects to output to the screen (to keep html separate from php) but I'm concerned about the overheads in a real situation. is there a better way of doing this?
example of a template file:
just wondering if there's a better way of doing this, and how you'd go about doing it - I thought about fopen and fread but that won't allow me to parse the variables in the template file.
if it's ok using includes to do it, i'll carry on that way, but I just thought I'd ask.
Code:
public static function render($arrb,$template) {
if (is_array($arrb)) {
foreach ($arrb as $b) {
include($template);
}
}
}
example of a template file:
Code:
<h2><a href='/blog.php?p=<?php echo $b->blog_id ?>'><?php echo $b->title ?></a></h2>
<h3><?php echo $b->posted ?></h3>
<div class='entry_body'>
<?php echo $b->entry ?>
</div>
<p><a href='/blog.php?p=<?php echo $b->blog_id ?>#comments'><?php echo $b->nophrase ?></a></p>
<p><?php echo $b->tag ?></p>
just wondering if there's a better way of doing this, and how you'd go about doing it - I thought about fopen and fread but that won't allow me to parse the variables in the template file.
if it's ok using includes to do it, i'll carry on that way, but I just thought I'd ask.