> On Mar 12, 2022, at 5:44 AM, Lynn <kja...@gmail.com> wrote:
> 
> Variable variables should be removed from PHP asap. It's 2022 and I still
> encounter bugs due to this "working" in legacy applications.



> On Mar 12, 2022, at 5:48 AM, Kamil Tekiela <tekiela...@gmail.com> wrote:
> 
> +1 on removing variable variables as soon as possible.



Variable variables provide functionality[1] that if removed would force major 
rewrites of PHP applications that were architected in a way that depends on 
that functionality. 

And while probably between 90% and 99% of the time when someone uses variable 
variables there are better alternatives, variable variables make certain code 
possible that would be impossible without them.

So, *assuming* removing variable variables is important enough to break any the 
existing code that uses it — sourcegraph.com reports[2] 162.2k examples of its 
use — PHP should at least add a function that would allow getting the variables 
value by name.  Something like `get_variable_value_by_name($name)` but 
hopefully with a less verbose name than I used in my example just now.

#jmtcw

-Mike

[1] https://stackoverflow.com/questions/16339658/php-variable-value-from-string 
<https://stackoverflow.com/questions/16339658/php-variable-value-from-string>
[2] 
https://sourcegraph.com/search?q=context:global+lang:php+%5B%5E:%5C%5C%5D%5C%24%5C%7B%5C%24++count:all&patternType=regexp
 
<https://sourcegraph.com/search?q=context:global+lang:php+[^:\\]\$\{\$++count:all&patternType=regexp>

Reply via email to