0

why its so important to identify Global variable and local variable?please explain with a simple e.g.

17th May 2020, 10:13 PM
LIAKOT HOSSAIN
LIAKOT HOSSAIN - avatar
2 Antworten
+ 1
Yes it is important because both of them contain value. But the main problem is that local variable can only be used in a function you can't acces it value from outside the function but in the case of global variable you can do so.
17th May 2020, 11:57 PM
Ayush Kumar
Ayush Kumar - avatar
+ 1
Short answer, Global is accessible everywhere, if the file is actually included in your script. Local variables are accessible within their parents scope, e.g. A variable defined inside a function is only accessible within the function. If everything was global it would be very easy to override important variables, or simply collide with others. Brgds
18th May 2020, 9:10 PM
Victor Andersson
Victor Andersson - avatar