4. Getting displayed text into PHP variable

To get displayed text into PHP variable, use expand() method or fetch() method.

$output = '';
$tmpl->expand($output, $model_data);
    

or

$output = $tmpl->fetch($model_data);
    

The method fetch() returns only XML text embedded with data, but does not an error object.