Results 1 to 4 of 4
Thread: global variables
Aug 19, 2001, 07:32 #1
If I define a variable $var, and then define a function Func(), then I can't use the variable $var inside the function because the variable is defined outside the function. If I want to use the variable $var inside the function, then I have to send it as a parameter in the function header like this, Func($var).
But the problem is that I have many global variables, and many functions. I don't want to pass all these variables to all the functions!
Isn't there a way that the functions can recognize my global variables without sending these variables as parameters in the function headers?
Aug 19, 2001, 07:40 #2
Use global inside the function. For example:
global $myvar1, $myvar2;
Aug 20, 2001, 08:32 #3
- Join Date
- Jan 2001
- Alkmaar, Netherlands
- 0 Post(s)
- 0 Thread(s)
u ask for advice and I see that u get the answer in 4 minutes but there is faster method for this kind of base questions: www.php.net
just enter global in search box and search whole site. Look at the top link. Fast huh?
Aug 20, 2001, 12:03 #4
Yes, but it is nice to talk to people!