NameSilo

Parsing file opened using fread

Spaceship Spaceship
Watch

lee101

Established Member
Impact
9
Hi,
I have created a script that opens a template in order to show thepage, and used str_replace to "dynamically" update the elements, similar to this:
http://www.namepros.com/code/189417-php-template-system-php4-5-a.html
Although one of the things I want to do is:
replace whever it says {CONTENT} with
PHP:
<?php include($page); ?>
Which i can do, although then the PHP code just shows up on the page, so it seems like it needs to be parsed (right word?) again, and I can't fund any functions to do that, is there any way for thisto be done?
Here is the PHP code:
PHP:
<?php
//open the configuration file
include('config.php');
//open the functions file
include('functions/functions.php');
//page variables
$page="index.php";
?>
<?php
//open the page template
$template=getconf('template');
$template='template/'.$template.'/index.htm';
$handle=fopen($template,'r');
$display_template=fread($handle,filesize($template));
fclose($handle);
//prepare image and css links for viewing
$display_template=str_replace('elements/','template/'.getconf('template').'/elements/',$display_template);
//prepare all other template features
$display_template=str_replace('{PAGE_TITLE}',getconf('page_title'),$display_template);
$display_template=str_replace('{FOOTER}',getconf('footer'),$display_template);
$display_template=str_replace('{HEADER}',getconf('header'),$display_template);
$display_template=str_replace('{CONTENT}',$page,$display_template);
echo $display_template;
?>

Thanks, Lee
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
ok, it doesn't matter now, i fixed it, used
PHP:
ob_start();
$template=getconf('template');
include('template/'.$template.'/index.htm');
$display_template = ob_get_contents();
ob_end_clean();
Instead
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back