Template Driven PHP Architecture
By Inforlinx2004-06-23
The PHP file
handler.php
<?php
1: $template_filename = "TEMPLATE.html";
2:
3: ..... database extraction codes (omitted) ....
4:
5:/*============================ */
6:/*=======Replacement Rules === */
7:/* =========================== */
8:
9: $replacement_rules = array (
10: array ("<!--NAME-DATA-->", "0"),
11: array ("<!--ADDRESS-DATA-->", "1")
12: );
13:
14: /* ========================= */
15:
16: $n_fcontents = template_parser ($template_filename, $replacement_rules, $recordset_array);
17: while (list ($line_num, $line) = each ($n_fcontents))
18: {
19: echo "$line";
20: }
?>
Replacement rules here may refer to a validation criteria or any control mechanism that specifies the content of the address book.
What the above script does is to set rules to display our database-retreived record fields in appropriate columns in the HTML tables. These rules will be stored in $replacement_rules array as defined above.
The elements of $replacement_rules array simply let our script know how to "fill in the blanks".
Tutorial pages:
|
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Template Driven PHP Architecture"
You must be logged in to post a comment.
Link to This Tutorial Page!

