What's the PHP equivalent of a static variable in other languages?

后端 未结 6 1443
执笔经年
执笔经年 2021-02-09 07:15

I\'m wondering if PHP has a type of variable in classes that functions like static in other languages. And by that I mean all objects of the same class use the same variable and

6条回答
  •  忘掉有多难
    2021-02-09 07:53

    I think static is the keyword you are looking for.

    And there is nothing that prevents a static property from beeing "updated", in PHP : it is initialized the first time it's set, it keeps it value during the execution of the PHP script, but you definitly can set it to a new value.

提交回复
热议问题