When to use a variable variable in PHP?

后端 未结 8 1737
-上瘾入骨i
-上瘾入骨i 2021-01-03 03:49

I\'ve been developing in PHP for a while now, and I still have not had a task where I\'ve had to use variable variables. Can anyone give me examples where using them is a go

8条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 04:23

    It's not uncommon for languages to include features you shouldn't touch with a bargepole (I even asked a question about it a while back), and variable variables are probably one of those constructs that fall into this category. Just because a language contains a feature doesn't mean to say you have to use it.

    There may be occasions when they solve a problem (after all recursion is rarely used in practice but no-one would argue that's not an essential construct) but in general any language feature that obscures what your code is doing, and variable variables defiantly fall into this category, should be treated with extreme caution.

提交回复
热议问题