When a statement is executed inside a function all the variables and corresponding variable values are
deleted.
In certain situations we want local variables to retain their value so they can be used elsewhere.
To do so we can use the static keyword when D when declaring the variable as shown in this example we
have setup function named test 1 inside this function.
We've declared a static variable X and assigned an initial value of 10.
Next we have an echo statement to output the value of x followed by the x plus plus statement which
will increment the value of X by 1.
Every time the function is executed
as we can see here below we've executed this function.
One two three four times each time it outputs the value of x plus 1 starting with an initial value of
10 so you can see that in our web browser the initial value is 10 which is also the initial value of
our x variable
since we've used a static keyword that variable value is stored and every time the function runs again
it takes that stored value and adds 1 to it.
So then so after the initial 10 we'd have 11 12 and 13 in that you can see is correct.
It's in our web browser.