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.
Template: file_get_contents Problem
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Template: file_get_contents Problem
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).
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Template: file_get_contents Problem
Use include() wrapped with the output buffering functions to capture the output.
(#10850)
Re: Template: file_get_contents Problem
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:
It outputs "This is the include: 1"
When the code in the include is really:
I'm not sure I understand about using output buffering (ob_start?). Can you explain?
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;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?