0
why its so important to identify Global variable and local variable?please explain with a simple e.g.
2 ответов
+ 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.
+ 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