Demo 8 - Demonstrating Scope

Variable Name
Where Defined
Effect
variable 1 php_demo8.php3 (main) Available in php_demo8.inc (main), but not in function demo8_function2()
variable 2 php_demo8.php3 (main) Variables defined in the $GLOBALS array are available everywhere
variable 3 php_demo8.php3 (main) Variable3 is just like variable1, except it is available inside of the function demo8_function2() because it is defined as as globally available inside of the the function.
variable 4 demo8_function1() (function) Variable4 is not available anywhere but in the function where it was defined because it was not defined as a global.
variable 5 demo8_function1() (function) Variable5 is available anywhere (where it is declared globally available) because it was defined a global in function demo8_function1()



Outside of a used defined function, php variable1 = Variable1 is available!

Outside of a used defined function, php variable2 = Variable2 is available!

Outside of a used defined function, php variable3 = Variable3 is available!

Outside of a used defined function, php variable4 =

Outside of a used defined function, php variable5 =



Inside of the user defined function, php variable1 =

Inside of the user defined function, php variable2 = Variable2 is available!, since it is in the $GLOBALS array.

Inside of the user defined function, php variable3 = Variable3 is available!, but only if defined as global

Inside of the user defined function, php variable4 =

Inside of the user defined function, php variable5 = Variable5 is available!, but only if defined as global here and in demo8_function1()