Re[2]: [PHP] Working with a Front Page developer
| From: | Richard Davey | Date: | Tue, 10 Feb 2004 19:30:16 +0000 |
| Subject: | Re[2]: [PHP] Working with a Front Page developer | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177311@lists.php.net to get a copy of this message | ||
Hello Chris,
Tuesday, February 10, 2004, 7:19:35 PM, you wrote:
CdV> Got any tips on writing a template system? Anything I should be aware of,
CdV> other than copious use of preg_replace? :-)
You don't have to use preg_replace, in its most "simplest" form the
following code will work just fine for a basic template system:
/*
Creates 2 arrays - src and dst. Src is a list of the "tags" to
search for in the HTML template and Dst is an array of the values to
replace them with. The template is then loaded into a variable, a
quick str_replace() function is performed and the output is
displayed with a header/footer wrapped around it.
*/
$src = array("&fontcolor&", "&body&",
"&submit&", "&error&");
$dst = array("red", $body, "Submit", $formerror);
$template = fileread("your_page.html");
$page = str_replace($src, $dst, $template);
include "header.php";
echo $page;
include "footer.php";
--
Best regards,
Richard mailto:rich@launchcode.co.uk