<?php 
if (!extension_loaded("htmltmplpro")) {
  print "htmltmplpro extension is not loaded";
} else {
  /*
   QUICKSTART
   */

  // create object
  $tmpl = new TemplateEngine();


  // set source (string). The set source file example is below.
  $tmpl->setInputString("
<HTML>
<body>
<H1> test addition</H1>
<b><tmpl_var EXPR=\"(10+TWENTY+FOURTY)>0\"></b>
loop:
<tmpl_loop L1>inside:<tmpl_var IN_LOOP></tmpl_loop>

call userfunc:<tmpl_var EXPR=\"entities('<')\">

</body>
</HTML>
");  // the same, but tempalte is loaded from file.


  // setting options
  $tmpl->setopt("default_escape", TemplateEngine::OPT_ESCAPE_HTML);
  $tmpl->setopt("tmpl_var_case",  TemplateEngine::ASK_NAME_LOWERCASE);

  // setting user defined functions. key is template name, value is php name.
  $tmpl->setopt("functions", array('entities'=>'htmlentities'));

  // creating parameters tree.
  $param = array(
	       'TWENTY'=> 20,
	       'FOURTY'=> 40,
	       'L1'=>array(
			   0=>array('IN_LOOP'=>'inner loop value 1'),
			   1=>array('IN_LOOP'=>'inner loop value 2')
			   ),
	       );
 
  // output.
  echo $tmpl->output($param);

  // or use print()method. 
  $tmpl->print($param);
?>

another example.
<?php 
  $tmpl1 = new TemplateEngine();

  // the same, but tempalte is loaded from file.
  $tmpl1->setInputFile("1.tmpl");
  $tmpl1->setopt("path", Array("templates"));

  // the rest is the same
  // ...
?>
