Re: Templating, or can I do this in php?

"Bill H" <bill@xxxxxxxxx> schreef in bericht news:139b6366-40ee-4cee-bf4c-3fe2b255d656@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
A little background, for 10+ years I have been a perl designer, all my
websites used perl. When desigining websites I would use SSI (.shtml)
to interface with perl programs for dynamic content, or build pages on
the fly from html fragments (partial web pages that contained elements
that would be combined into a completed page based on the current
user, their request etc). The reason behind this is that I wanted to
keep the presentation as seperate from the logic as much as possible.

I am now working in php and would like to continue this process,
create the webpages in a WYSIWIG and then either add php tags on parts
of the page where it is needed (ala SSI and the <!--#include>) or have
fragments that are pulled in by php to build the pages on the fly. I
have been able to accomplish this with one problem, if a page pulled
in (read from the disc) contains php tags, these do not get executed,
the tag just gets sent out to the browser. Is there a way to have php
process tags that may be in a file that I read in using

A very simple example:


print file_get_contents("template.htm");


where template.htm contains:

<P><?php print phpinfo(); ?></P>

When I run the example script the tag <?php print phpinfo(); ?> ends
up in the browser. If I rename template.htm to template.php and run
that it works.

Bill H

try include, include_once, require or require_once.

$ php -f a.php ; cat a.php b.html c.html
a start
b start
c start
c end
b end
a end
echo "a start\n";
echo "a end\n";
echo "b start\n";
echo "b end\n";
echo "c start\n";
echo "c end\n";