Since most common use of
execute() method is to echo its output, PHPTAL offers convenience method that echoes output immediately without buffering. This enables streaming of arbitrarily large output without hitting memory limit.
Fragments of template that use
phptal:cache are buffered regardless.
<?php $tpl = new PHPTAL('template.xhtml'); $tpl->echoExecute(); ?>
is same as:
<?php $tpl = new PHPTAL('template.xhtml'); echo $tpl->execute(); ?>
but little faster.
echoExecute() method has some unexpected limitations.
echoExecute() is used, PHPTAL will throw exception if you call any macro defined in a file that has XML declaration or DOCTYPE.
Typically PHPTAL allows templates to "inherit" DOCTYPE from another file (useful when subpage is calling main layout template), however that is not possible without buffering.
To work around this you can:
echo $tpl->execute() until this limitation is lifted.
Remove all DOCTYPEs and XML declarations from templates and echo them from PHP before calling