Variable Scope PHP3 Manual Prev Chapter 5. The scope of a variable is the context within which it is defined. For the most part all PHP variables only have a single scope. However, within user-defined functions a local function scope is introduced.
Any variable used inside a function is by default limited to the local function scope.
You may notice that this is a little bit different from the C language in that global variables in C are automatically available to functions unless specifically overridden by a local definition. This can cause some problems in that people may inadvertently change a global variable. In PHP global variables must be declared global inside a function if they are going to be used in that function. There is no limit to the number of global variables that can be manipulated by a function. Another important feature of variable scoping is the static variable.