Names of Variables
The rules for naming of Identifiers(Variables ,Methods and Classes) is basically the same as in other languages.
Names can begin with an alphabet, $ or _.
- All these are legal names: $a=10, $_a=1, _$a1,a1, ab1cd etc.
- Keywords cannot be names but can contain keywords.
Thus char. class etc is not allowed.
However classname, charname, nameofchar etc is allowed.
Scope of Variables
A variable declared outside of all functions is global. A variable declared inside a function but not prefixed with var is also global.
of valid and invalid variables in this page.
Valid and Invalid Variables