PHP - valid variable names

前端 未结 2 1599
梦毁少年i
梦毁少年i 2021-02-04 07:20

In the PHP manual on variables, we can read:

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter o

2条回答
  •  死守一世寂寞
    2021-02-04 07:53

    I've seen on php.net (spanish version) things like $función, $año * and so, always wanted to try, but never did. However, for some reason I wrote some vars like $1a ($1st), $2a, $3a... And it worked, no '${1a}' or stuff needed, but, Phpstorm is nagging me with warnings like "Expected: semicolon" and "Expression is not assignable: Constant reference". So, after reading your experiences in this article, and to clean my editor from warnings and avoid possible future problems, I just changed everything to $a, $b, $c, etc. Note: $ano (year) in spanish is anus, so nobody likes to use it

提交回复
热议问题