Dependencies with templates

A very basic and functional example of what I believe your trying to achieve could be:

function template($path, $global=null) {
  //Extract any global set values
  if (!empty($global)) {
     extract($global);
     }

  ob_start();
  include $path;
  $contents = ob_get_contents();
  ob_end_clean();

  return $contents;
  }

$global_array = array('pageOwner' => 1,
                      'info' => array()); //etc.

echo template('/path/to/template/file', $global_array); 

The key used in the global array decide the variable name it get when parsed in the function, i.e. ‘pageOwner’ become $pageOwner etc.

If you want to make your own solution, the code above can refactored into OOP with getter/setters etc. to fit what you need.

In the event you just need a basic template engine, Twig would not be a bad choice.