The global key word can be used to access global variables that are inside a function.
In this example we have two global variables x and y x with a value of 30 in Y with a value of 20 inside
the function named test 1 we've used the global keyword to access the values of variable x and y to
confirm that this worked.
We've set variable Y equal the sum of X plus Y
so we'll go ahead and execute this function by calling function test 1 and also by outputting the new
value variable Y which we know should be 50 which is 30 plus 20 so we can see in a web browser that
50 is in fact output.
So the global keyword has worked for its purpose
it's important to note that P HP stores all global variables in an array variable called Global's an
array is a special variable that can store multiple values.
We'll be exploring a rate arrays leader in this course the array index holds the name of a variable
so we can rewrite our existing code as follows
so we can see that here we're referencing global variable Y which we're setting to the sum of global
variable x plus global area y.
And once again the output should be the exact same 50.