Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Templating, or can I do this in php?
November 22, 2008, 2:11 pm
rate this thread
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:
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.
Re: Templating, or can I do this in php?
try include, include_once, require or require_once.
$ php -f a.php ; cat a.php b.html c.html
echo "a start\n";
echo "a end\n";
echo "b start\n";
echo "b end\n";
echo "c start\n";
echo "c end\n";