global vars inside includes inside functions?

From: Date: Thu, 29 Apr 2004 04:27:39 +0000
Subject: global vars inside includes inside functions?
Groups: php.general 
Request: Send a blank email to php-general+get-184922@lists.php.net to get a copy of this message
Can someone see a way to achieve what I want? I have the following function: <? function safeInclude($file) { if(file_exists($file)) { include($file); } else { debug("file $file not found"); } } ?> When used in this context... <? $something = 'foo'; safeInclude('somethingElse.inc'); ?> ... somethingElse.inc cannot see the global variable $something. So, if an include is wrapped in a function, it would appear that the global variables no longer apply to the namespace of the included file. Is there anyway I can get around this? My only guess is I could add the line "global $GLOBALS;" to safeInclude(), but I have no idea how this affects memory usage or anything else. --- Justin French http://indent.com.au

« previous php.general (#184922) next »