If you declare a variable outside a procedure, you make it recognizable to all the procedures in your script. How long a variable exists is its lifetime. The lifetime of a script-level variable extends from the time it's declared until the time the script is finished running. At procedure level, a variable exists only as long as you are in the procedure. When the procedure exits, the variable is destroyed.
Local variables are ideal as temporary storage space when a procedure is executing.
You can have local variables of the same name in several different procedures because each is recognized only by the procedure in which it is declared. Variables Much of the time, you just want to assign a single value to a variable you've declared. A variable containing a single value is a scalar variable. Other times, it's convenient to assign more than one related value to a single variable. Then you can create a variable that can contain a series of values.