Re: templates with php
| From: | Rasmus Lerdorf | Date: | Mon, 31 Jul 2000 16:10:28 +0000 |
| Subject: | Re: templates with php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9189@lists.php.net to get a copy of this message | ||
> I'm starting a new project from scratch and I my idea is do it with html
> templates. What I mean is a directory with some templates like index.html,
> details.html, checkout.html, etc, which one with symbols in it, like
> @title@, @price@, @description@, etc... When the page is requested some
> kind of pre-processor reads variables and show the dynamic page. My
> question is how can I do that with php? What's the best way?
My personal approach to this is to use an auto_prepend_file directive
that tells PHP to automatically include a PHP script. Then in that I
create the various functions and my "template" files are simple PHP files
that simply call the functions. ie. <?title()?> <?price()?>
<?description()?>
I never understood why people are so insistent on using something like
@title@ instead of <?title()?> at the cost of an order of magnitude of
performance degradation.
-Rasmus