what is scope of variables
Answers
Scope of Variables
Scope refers to the visibility of variables. In other words, which parts of your program can see or use it.
Once defined, every part of your program can access a variable.
Scope of Variables in C
A similar concept applies to variables in C. Variable scope refers to the accessibility of a variable in a given program or function.
Example :-
A Variable may only be available within a specific function (your apartment key), or it may be available to the entire C program (the shared access key).
Scope of Variables in Java
The scope of a variable is the region of a program in which the variable is visible, i.e., in which it is accessible by its name and can be used.
In Java, the scope of a local variable is the body of the method in which it is declared.
Scope of Variables in PHP
Depending on the scopes, PHP has variable scopes:-
The variables declared within a function are called local variables to that function and has its scope only in that particular function.
In simple words it cannot be accessed outside that function.
- Hope it helps...