Page 1 of 1

Function Variables

Posted: Thu Jun 19, 2003 4:06 am
by Gen-ik
I really should know this but is there a way of setting up a variable in PHP so that it can be read by any function.. without having to keep sending that variable to a function everytime it's called.

I know I could use classes but it's not worth the overhead for what I'm doing.

Basically if I set $MyName I would like to be able to access and change this variable from any where in the PHP code.. including functions().


Any ideas would be a big help.


Thanks.

Posted: Thu Jun 19, 2003 4:14 am
by []InTeR[]
I don't know exectly but i think import_request_variables will do the trick.

Posted: Thu Jun 19, 2003 4:34 am
by Wayne
not sure if this is exactly what you want but you could use

$GLOBALS['MyName'] instead of $MyName

sorry dont know of any other way around it, besides declaring the variables as GLOBAL in all the functions.

Posted: Thu Jun 19, 2003 7:47 am
by Gen-ik
Ahhh.. got it. I knew it would be simple. I'm using the global $MyName way of doing it in each of the functions.... seems like the easiest way.

Cheers guys.