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:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php