3.1.11. fetch()

mixed fetch ( string $filename [, bool $display = false] )

Executes the template in the $filename file and returns it as a function result ($display = false) or sends it to the browser ($display = true). The second parameter is used mostly by OPT and you do not have to worry about it. Contrary to the first OPT versions, you may use both returning as function result and to the browser at the same time and at the same template.

The executed template sees the blocks assigned before calling this method, but it does not remove them after parsing, so you may use them again.

Example 3.5. fetch()

<?php
    // Use OPT for mail parsing
    $tpl -> assign('title', 'Message title');
    $tpl -> assign('email', '[email protected]');
    mail('Automessage', '[email protected]', $tpl -> fetch('mail.tpl'));
?>

See also: optClass::parse(), optClass::parseCapture()