Wednesday, May 16, 2012

PHP file includes inside function, need to retain global variables. (Trying to wrap HTML comments)

In an attempt to speed up my workflow and help the back end guys with integration (I'm a front end dev) I'm attempting to extend the file includes function by wrapping comments around each file include to output it's filename:

function include_module($path) {
echo "\n\n<!-- MODULE: ".basename($path, '.php')." -->\n";
echo "\n<!-- /MODULE: ".basename($path, '.php')." -->\n\n";

However this results in the loss of access to any variables set outside the function. I know I can do:

global $var

But that will only give me access to $var (I'm aware I could do $var['var1'], etc), is there any way to do 'global all' or can anyone think of a different approach to wrap the comments?

Cheers :)

No comments:

Post a Comment