Jochem Maas wrote:
short of playing around with the global keyword
(which won't work when you call includeIt() from
another function)) your pretty much stuck.
basically imho you need to rethink what it is your trying to do.
function have their own scope for a reason; maybe consider using
an array argument like so:
function incIt($file, $args = array())
{
extract((array)$args);
include $file; // don't forget some error checking
}
function includeIt($file, $args = array())
{
// bla
incIt($file, $args);
// more bla
}
I broke it down into 2 functions to avoid local variables
being overridden in includeIt() [by the call to extract].
In addition to your solution, it is needed to transfer the variables by
reference.
Your solution is good when you know what variables you want to transfer
ahead, and then make a list of them. But if I want to transfer all the
variables in the current environment scope?
-thanks, Eli.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php