5.5.1:Variable Scope

変数の有効範囲

The scope of a variable is the part of the application where the variable can be used. If you refer to a variable in a handler that's outside the variable's scope, you'll get either an execution error or an unexpected result.

変数の有効範囲とは、変数が使われるアプリケーションの重要な部分です。ハンドラで有効範囲を超える変数を参照すると、実行エラーになるか想定外の結果を得ることになります。

There are three levels of variable scope:
local, script local, and global. Every variable is one of these three types. The difference between these types is in where they can be used and how long their value lasts.

変数の有効範囲には次の三段階があります:ローカル(local)、スクリプト・ローカル(script local)そしてグルーバル(global)です。変数はどれのこの三つの形式のいずれかになります。この三つの違いとは、どこでこの変数が使われるのかと、その変数の値がどれくらい長く有効か、の二点に集約されます。