krycek
03-21-2003, 04:50 PM
OK.
Firstly, global variables. To use a script-level variable inside a function, I have to declare it as global INSIDE the function. For instance, if my script sets up $myVar, then to see $myVar, I have to say, global $myVar inside the function.
Is there any way to do this from OUTSIDE the function...? Without using the $GLOBALS array? So that that variable will be global for ALL functions without me having to declare it each time...?
Secondly, using external variables as defaults in function. You know that if you DON'T pass a value to a set argument, then you can have a default argument value...? Such as, function myFunc($myVar = "hello"). Passing anything through will use the passed value, otherwise "hello" will be used.
What I want to do, is to have the default value adhere to a variable - however, the function cannot see it! ...kinda like my first question, but maybe the answer is different.
Thirdly, existance. I can check if a variable is in existance by using isset(). But, how can I "see" outside of a function to determine whether or not a variable is set...? If I make it global, it will become set once I do, regardless of whether it is set or not. And, if I use isset() within my function, then of course that variable is not set within my function...
So, these are headaches to me at present. Any ideas and advice would be welcomed :)
::] krycek [::
Firstly, global variables. To use a script-level variable inside a function, I have to declare it as global INSIDE the function. For instance, if my script sets up $myVar, then to see $myVar, I have to say, global $myVar inside the function.
Is there any way to do this from OUTSIDE the function...? Without using the $GLOBALS array? So that that variable will be global for ALL functions without me having to declare it each time...?
Secondly, using external variables as defaults in function. You know that if you DON'T pass a value to a set argument, then you can have a default argument value...? Such as, function myFunc($myVar = "hello"). Passing anything through will use the passed value, otherwise "hello" will be used.
What I want to do, is to have the default value adhere to a variable - however, the function cannot see it! ...kinda like my first question, but maybe the answer is different.
Thirdly, existance. I can check if a variable is in existance by using isset(). But, how can I "see" outside of a function to determine whether or not a variable is set...? If I make it global, it will become set once I do, regardless of whether it is set or not. And, if I use isset() within my function, then of course that variable is not set within my function...
So, these are headaches to me at present. Any ideas and advice would be welcomed :)
::] krycek [::