In PHP there\'s a functionality officially called \"Variable Variables\" where one can assign variable variables. A variable variable takes the value of one variable as the
This has some uses when referencing variables within classes, and there are some cases where these can actually be required (such as in __get()
, __set()
, __isset()
, and __unset()
). However, in most cases it is unwise to use them on global variables.
Be aware that you should NEVER directly accept end-user input when it comes to variable variables. Instead a wrapper function should be used to ensure that only specific inputs are allowed.
In most cases, variable variables are not required, and it is recommended that you avoid them when possible.