Declares a global variable in a function.
EXTERN var1, var2, ..., varN
One or more variable names.
a = 10;
b = 20;
a == 10;
b == 4;
The SPL function myfun declares variable a as local and variable b as external or global. Thus, the global variable a is unaffected, but global variable b is assigned by myfun.
Global variables can be specified on a file basis.
c1 = myfun1();
c1 == 20;
a == 5;
b == 25;
c2 = myfun1();
c2 == 25;
Variables a and b are global variables accessible to both functions myfun1 and myfun2.
If a variable is not declared in an SPL function, it is assumed to be local.
File based external variables are initialized when the SPL function is first loaded, whether automatically loaded or explicitly loaded.
The extern keyword is the same as the GLOBAL keyword.
See LOCAL to specify local variables in an SPL function.
See STATIC to define local variables that are persistent across SPL function calls.