Including files for templates
| From: | Terry Burns-Dyson | Date: | Sun, 23 Mar 2008 11:32:57 +0000 |
| Subject: | Including files for templates | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-272008@lists.php.net to get a copy of this message | ||
I'm trying to write a template system, my template is the HTML layout, and my content is fetched from another source. However I don't quite understand how to output the template so that all the variables are parsed by PHP. Simple version of what I'm trying to do;
ob_start( );
extract( $params, EXTR_PREFIX_SAME, "am_");
$pageContent = file_get_contents( "page_to_display.html");
include( "template.html");
echo ob_get_clean( );
$pageTitle is in the template, it's replaced, $pageContent is in the template, it's replaced. But any variables within the page_to_display are simply output into the page rather than processed by PHP. I realise that file_get_contents is basically returning a string and I"m just doing string replacement when I include the template.html, so my only question is, what's the actual way of doing this?
Thanks