Page 1 of 1
Template: file_get_contents Problem
Posted: Fri Jul 25, 2008 10:58 am
by psurrena
I'm working on a template system and have a question about file_get_contents. In my template file, there is php for sessions, includes and so on. It seems that file_get_contents ignores all PHP, is there a function that does the same thing but doesn't kill the php?
Thanks.
Re: Template: file_get_contents Problem
Posted: Fri Jul 25, 2008 11:24 am
by JAB Creations
I've never tried this but I'm curious because if there is a solution it would have to do with program execution order...essentially A gets B but B must execute first...PHP in all my experience has (thus far) always done this. On php.net are there any functions in "see also" towards the bottom of the explanation just before the comments? I'm interested in this so I'm subscribed to the thread (but gotta go eat lunch now).
Re: Template: file_get_contents Problem
Posted: Fri Jul 25, 2008 11:53 am
by Christopher
Use include() wrapped with the output buffering functions to capture the output.
Re: Template: file_get_contents Problem
Posted: Fri Jul 25, 2008 12:18 pm
by psurrena
Here's how I have it set up (it's a three file system)...
url:
http://www.site.com/index.php?page=home
index.php grabs the value of page and includes the equivalent file, in this case
home.php.
home.php just includes content (paragraph, image, php).
index.php grabs the template and replaces the specified tags with the matching tags in
home.php.
Here's another odd thing. In home.php, if I use this code:
Code: Select all
$test=include('test.php');
$tags['body'].="This is the include: ".$test;
It outputs "This is the include: 1"
When the code in the include is really:
Code: Select all
$text= "<h1>this is an inlcude test</h1>";
I'm not sure I understand about using output buffering (ob_start?). Can you explain?