How can I make a regular variable accessible in files included by a class method?

I have a php site which flows as shown below. Please note I'm leaving out most of the code (wherever theres an ellipses).index.php\[code\]include template.php...$_template = new template;$_template->load();...\[/code\]template.php\[code\]class pal_template {...public function load() { ... include example.php; ...}\[/code\]example.php\[code\]...global $_template;$_tempalate->foo();...\[/code\]Now, this works fine. However, I end up having a ton of files that are displayed via the $_template->load() method, and within each of these files I'd like to be able to make use of other methods within the template class.I can call global $_template in every file and then it all works fine, but if possible I'd really like for the object $_template to be available without having to remember to declare it as global.Can this be done, and what is the best method for doing it?My goal is to make these files that are loaded through the template class very simple and easy to use, as they may need to be tweaked by folks who basically know nothing about PHP and who would probably forget to put global $_template before trying to use any of the $_template methods. If $_template were already available in example.php my life would be a lot easier.Thanks!
 
Back
Top