Re: Re: global vars inside includes inside functions?

From: Date: Thu, 29 Apr 2004 16:28:54 +0000
Subject: Re: Re: global vars inside includes inside functions?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-184962@lists.php.net to get a copy of this message
Hi, Friday, April 30, 2004, 1:29:12 AM, you wrote: RW> [...] >> <? >> function safeInclude($file) { RW> [...] RW> foreach ( $GLOBALS AS $k => $v ) { RW> $$k = $v ; RW> } RW> [...] >> if(file_exists($file)) { >> include($file); >> } else { >> debug("file $file not found"); >> } >> } >> ?> RW> [...] RW> (better, as no eval-syntax is required) RW> -- red That makes local copies only, still no access to the global variable The other thing to consider is that everything dies at the conclusion of the function. It may be better to do this via a class construct -- regards, Tom

« previous php.general (#184962) next »