templates PHP Eval that evaluates HTML & PHP

function render($script, array $vars = array())
{
    extract($vars);

    ob_start();
    include $script;
    return ob_get_clean();
}

$test = 'one';
echo render('foo.php', array('test' => 'two'));
echo $test; // is still 'one' ... render() has its own scope

I’m messing around with templating and I’ve run into a situation where I need to echo to the browser a template that contains html & php. How do I evaluate the PHP and send it to the browser? So

Source: templates – PHP Eval that evaluates HTML & PHP – Stack Overflow