NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Parsing file opened using fread

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-21-2006, 03:05 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Mar 2006
Location: United Kingdom
Posts: 413
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
 




Parsing file opened using fread


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-...-php4-5-a.html
Although one of the things I want to do is:
replace whever it says {CONTENT} with
PHP Code:
<?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 Code:
<?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));
????: NamePros.com http://www.namepros.com/programming/229950-parsing-file-opened-using-fread.html
fclose($handle);
//prepare image and css links for viewing
????: NamePros.com http://www.namepros.com/showthread.php?t=229950
$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
__________________
Linux Screenshots
lee101 is offline  
Old 08-21-2006, 07:28 AM THREAD STARTER               #2 (permalink)
NamePros Regular
Join Date: Mar 2006
Location: United Kingdom
Posts: 413
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
 




ok, it doesn't matter now, i fixed it, used
PHP Code:
ob_start();
$template=getconf('template');
include(
'template/'.$template.'/index.htm');
????: NamePros.com http://www.namepros.com/showthread.php?t=229950
$display_template ob_get_contents();
ob_end_clean(); 
Instead
__________________
Linux Screenshots
lee101 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:13 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger