Make global variables available to an included file within a function
<p>I need to include files within a function, and files use lots of variables defined earlier in the script.  Using global is not an option because it is impossible to say which variables will be used in included files.  The only one real solution is to make all global variables accessible in function, something like:</p>

<pre><code>     function finc($file)
    {

        foreach($GLOBALS as $k=&gt;$v)
        {
            $$k=$v;
        } 
        include $file;
   }
</code></pre>

<p>but it won't be good when using lots of files with lots of variables, so is there any better way to do it?</p>
