Globalise all varibles

i have different complex functions that i have made into functions from normal code, and i dont want to go thru the funtion and globalise the varibles individually, so does anyone no how to globalise all varibles???? i would really appreachiate an answer?
RavenClawAsked:
Who is Participating?
 
aolXFTCommented:
the name of the array is $GLOBALS and not $_GLOBALS

extract($GLOBALS)
0
 
shmertCommented:
extract($_GLOBALS);

this will put all the global variables into the current namespace for the function you are in.  It is also not a very efficient way to go, since it will create a copy of the entire $_GLOBALS array every time the function is called.
0
 
RavenClawAuthor Commented:
erm tried that just
but php error:
Warning: extract(): First argument should be an array
:\
0
 
RavenClawAuthor Commented:
brilliant thanks thats saved me a lot of time :)
0
 
aolXFTCommented:
nice to see you happy, but I don't think it will save your script a lot of time.

The following will probably be more efficient, since it uses references instead.

foreach(array_keys($GLOBALS) as $k){
  $$k =& $GLOBALS[$k];
}

having that said I haven't tested it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.