XiTemplate Home Page XiTemplate
[ class tree: XiTemplate ] [ index: XiTemplate ] [ all elements ]

Example usage of assign()

  1. <?php
  2. /*include the class*/
  3. include_once('../class.XiTemplate.php');
  4.  
  5. /*instantiate the class and pass the path to your html template file*/
  6. $xitpl = new XiTemplate('templates/assign.tpl');
  7.  
  8. /*assign a value to a template variable.*\
  9. /*In this example {NAME} will be replaced with "XiTemplate"*/
  10. $xitpl->assign('NAME', 'XiTemplate');
  11.  
  12. /*multidimensional array*/
  13. $myArray = array
  14. (
  15. 'name' => 'Jim',
  16. 'lastName' => 'Grill',
  17. 'address' => array
  18. (
  19. 'street' => 'One XiTemplate Way',
  20. 'city' => 'Paradise',
  21. 'state' => 'Hawaii',
  22. 'zip' => '12345'
  23. ),
  24. 'age' => 'too old'
  25. );
  26.  
  27. /*assign the array to a template variable*/
  28. $xitpl->assign('MYARRAY', $myArray);
  29.  
  30. /*parse the "main" block of the page (the whole page)*/
  31. $xitpl->parse('main');
  32.  
  33. /*send the final page out to the browser*/
  34. $xitpl->out('main');
  35. ?>

Documentation generated on Fri, 20 Aug 2004 10:57:45 -0500 by phpDocumentor 1.3.0RC3