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

后端 未结 6 913
逝去的感伤
逝去的感伤 2021-02-09 07:03

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:36

    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.

提交回复
热议问题