| Example 3 | |
|---|---|
| In this example we will work with alternating colors, evaluated PHP and constants. Program File
# 1: <?php
HTML template file
# 0: <?
Again, our php file bases on example 2 ; the differences:
First, we declare the constant G_HOSTNAME and fill it with $_SERVER['HTTP_HOST']. define("G_HOSTNAME", $_SERVER['HTTP_HOST']);
Then, instead of calling parseAndEcho() we call
$STP->parseAndEchoPHP();This will evaluate any one-line code in our template. Again, more changes can be found in the HTML template. To define the colors for the color change we set at the beginning <#ATTR cc0000,00cc00#>Now, all we have to do to change the colors is write <tr Bgcolor="#<#ATTR#>">into the FOR-loop. Please note the use of <#G_HOSTNAME#>that will expand to the name of your server domain We tell the user what time and date he entered by It is <?php echo date("H:i:s") ?> on <?php echo date("Y-m-d") ?>
Of course you could also define this in the php file; actually, you are encouraged to write as much as possible in to the php file and not into the template. We wanted to separate code and HTML, right?
However, sometimes there is no way around putting some php into a template. See the result Note: It is currently not possible (and not intended either) to put more than one consecutive line of php code into a template. |
| .GR - Domains for you |
No residence restrictions - anybody can register
Registration starting at € 16,33 / year
Web Hosting incl. .gr-Domain from € 8,90 / month
|