I’ve looked through the PHP documentation and it seems like this is possible, but it’s still dropping my variable values with global. Is there something I’m missing?
I set $var to a value. Then declare it global $var. Then the value shouldn’t change and I will be able to use it globally right? Forgive my ignorance, I’m new to this.
The
globalkeyword does not make a variable global, it makes the variable accessible in the context of a function.If you want to make a variable global you can use the
$GLOBALSarrayFrom the Manual: