3.1.2. assign()

void assign ( string $name, mixed $value )

Assigns the value to the $name block in the template. Use it also for assigning the section data. The method must be called before parsing the template. Already defined blocks are not lost after the template execution and you can still use them.

Example 3.1. assign()

<?php
  // Initialize OPT here
  $tpl -> assign('date', date('d.m.Y, H:i'));
  $tpl -> parse('template.tpl');
?>

template.tpl:

<p>Today is {$date}</p>