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 
$STP = new parser2;
$STP->setParam("HELLO","Hello World");
HTML template file # 0: <?
# 1:
# 2:   <
# 3:   <
title>Example 1</title>
# 4:   </
# 5:   
# 6:   <
# 7:   <
h1 align="center"><#HELLO#></h1>
# 8:   
# 9: </
So, what does it do here?
First we load the Parser file:
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:
Finally, the parser is told to print out the result:
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

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

My Sites