As mentioned, the Simple Template Parser functions as a divider between the code and the html. So we always have at least two files to edit.

By the way: The examples are part of the STP download so you can (and should) play with them at home!

Example 1
This is a very simple example to demonstrate the basic setup. Program File #1: <?php 
#2:
require_once("../stp.inc");
#3:
$STP = new parser2;
#4:
#5:
$STP->setParam("HELLO","Hello World");
#6:
$STP->setTemplate("example1.tmpl");
#7:
$STP->parseAndEcho();
#8:
?>
HTML template file # 0: <?
# 1:
<html>
# 2:   <
head>
# 3:   <
title>Example 1</title>
# 4:   </
head>
# 5:   
# 6:   <
body>
# 7:   <
h1 align="center"><#HELLO#></h1>
# 8:   
</body>
# 9: </
html>
So, what does it do here?
First we load the Parser file:
require_once("./stp.inc");
Now we create a new instance of the parser2 class:
$STP = new parser2;
Next we set the parameter "HELLO" with the value "Hello World":
$STP->setParam("HELLO","Hello World");
Now we tell the parser where to find the template to use for the output:
$STP->setTemplate("example1.tmpl");
Finally, the parser is told to print out the result:
$STP->parseAndEcho();
In our template file example.tmpl the parser will now find the tag . It will then check if it has a parameter by this name and if so replace it.
See the result

Important:
If the parser does not find a parameter that matches a given tag this tag will be stripped.

My Sites