Re: Export local variable to global variable scope?
- From: "Rik Wasmus" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Sun, 30 Sep 2007 15:01:12 +0200
On Sat, 29 Sep 2007 19:27:28 +0200, howa <howachen@xxxxxxxxx> wrote:
On 9 29 , 9 49 , Bruno Barros <rage...@xxxxxxxxx> wrote:On 29 Sep, 13:23, howa <howac...@xxxxxxxxx> wrote:Assume that I know nothing about the stuffs inside bar.php...is it
> I have a function, e.g.
> function foo() {
> include("bar.php");
> }
> and the bar.php contain contents e.g.
> $global_v1 = "abc";
> $global_v2 = "def";
> I want to execute function foo(), but at the same time, let the
> variables declared in bar.php to have global scopem is it possible?
function foo() {
global $global_v1;
global $global_v2;
include "bar.php";
}
possible?
function foo(){
include_once('bar.php');
foreach(get_defined_vars() as $name => $value){
if(!in_array($name, array('_GET','_POST','GLOBALS','_COOKIE','_SESSION','_ENV','_FILES','_REQUEST','_SERVER')))
$GLOBALS[$name] = $value;
}
}
It's really kinda ugly though.
--
Rik Wasmus
.
- References:
- Export local variable to global variable scope?
- From: howa
- Re: Export local variable to global variable scope?
- From: Bruno Barros
- Re: Export local variable to global variable scope?
- From: howa
- Export local variable to global variable scope?
- Prev by Date: Re: Do you use _set?
- Next by Date: Re: newbie question: <?=$variable?> yields no output
- Previous by thread: Re: Export local variable to global variable scope?
- Next by thread: Re: Export local variable to global variable scope?
- Index(es):
Relevant Pages
|