Ok, I don't have a clue why my variables never seem to work unless I set them and use them all in the same method.
can somebody help to clear some things up for me?
This is what I understand about the scope of variables (tell me if any of it is wrong):
- when you declare a variable GLOBAL it must be in the same function where you set it's value. After this you can use it anywhere within a document.
- when you have a class, you can declare variables with VAR in front of them provided they aren't inside a function. After this, you can set and use the variable anywhere inside that class.
some Q's....
If you have a class with VAR $variable and you create another variable inside a function called GLOBAL $variable2, can you use $variable2 outside of that class?
... and what if they were both called $variable.... would they be the same thing, or whould they hold seperate values.
... also, when calling a variable from outside a class what is the syntax. ($objName->variableName ???)
Anything else that I should know would be great, because I can't seem to get any values outside where I set them. 🙁