PHPlib
Friday, July 25, 2008  
download | documentation | faq | changelog | resources 


search for in the  


previousTemplate Instance methods
Object Oriented HTML Formsnext

Last updated: Thu, 04 Jul 2002
view this page in Plain HTML

The class manages a set of variables which are text strings. These strings may contain references to other variables in the form of "{variable}". When parsed or substituted, a variable reference is being replaced by the value of that variable. For example, if you

will print the value of a is defined as hugo.

A variable value may be defined manually by calling set_var("name", "value"); or it may be defined from a file by calling set_file("name","filename.ihtml");. In the latter case, the contents of the file are being loaded when needed (as late as possible) and set as the value of that variable.

A third way to define a variable value is to call set_block("parent", "block", "name");. In this case, the variable named parent is being searched for a block that starts with <!-- BEGIN block --> and ends with <!-- END block -->. This string is removed from the variable parent and assigned to the variable named block. In parent, a variable reference to name is placed instead. If the optional parameter "name" is left out, "block" is being used instead.

For example, if you

this will define the variable a as front matter {bb} end matter and the variable b as this is block b. All of this will become more clear when you set the instance variable debug to 7 in the following example and trace the variable accesses.

Use Template direcly or define a subclass of Template as needed.

Define a template file named page.ihtml as follows:

This file contains a reference to the variable PAGETITLE and a reference to the variable named OUT. Another reference to the variable named UNDEFINED_VARIABLE is never resolved. Another template file, named box.ihtml, contains a block named row with three variable references {TITLE}, {NUM} and {BIGNUM}:

The following php3 file demonstrates how to use these templates:


User Contributed Notes
Template Examples
add a note about notes
There are no user contributed notes for this page.


previousTemplate Instance methods
Object Oriented HTML Formsnext

Last updated: Thu, 04 Jul 2002



 

PHP Copyright © 2001 The PHPlib Group
All rights reserved.
Last updated: Thu Jul 4 15:33:16 2002 IST
Hosted and Maintained by http://www.sanisoft.com