I had another look at my earlier reply and fixed some things. Instead of making everything global, how about playing around with extract() and function scope?
Originally Posted by Young Twig
So there's a test.php:
$data = array // practically would be taken from database
'username' => 'Fred',
'page_title' => 'Admin'
function view($array, $file) // Two line templating system?
<?php view(array ('page_title' => $page_title), 'header.php') ?>
Welcome back, <?=$username?>!
<?php view(array(), 'footer.php') ?>
Each call of view() creates a scope that the variables are unpacked into for the PHP template, as far as I have tested. Though I'd be interested in what other people think of the code; I've never used it in a production environment.