HTML_Template_IT::setVariable() – set a variable


require_once 'HTML/Template/IT.php';

void HTML_Template_IT::setVariable ( mixed $placeholder , mixed $variable = "" )


Set the value of a variable in the current template block. If $placeholder is an array, the key of an element is treated as a placeholder name while the value is treated as its substitution.


  • mixed $placeholder - name of the placeholder to substitute or a array with the placeholder as key and the data to assign as value.

  • mixed $variable - if $placeholder is not a array, the value to assign to the placeholder.


Template - cvsnames.tpl.htm

<!-- BEGIN row -->
    <!-- BEGIN project_row -->
    <!-- END project_row -->
<!-- END row -->


require_once "HTML/Template/IT.php";

$data = array
"0" => array("cvs_username" => "pajoye"
"realname" => "Pierre-Alain Joye",
"projects" => array("PEAR"
"1" => array("cvs_username" => "dsp",
"realname" => "David Soria Parra",
"projects" => array("HTML_Template_IT"))

$tpl = new HTML_Template_IT("./templates");


$data as $name) {
// Assign data to the inner block
     foreach (
$name['projects'] as $projectname) {
// use the possbility to set the placeholders using an assoc array
"CVS_USERNAME" => $name["cvs_username"],
"REALNAME" => $name["realname"])


// show() parses the __global__ block and
  // print the output



This function can not be called statically.

set a template (Previous) print a block including replacments (Next)
Last updated: Tue, 24 Nov 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.