PHP and Static Variables in Object Member Functions

后端 未结 3 1807
陌清茗
陌清茗 2021-01-04 00:13

Up until today, I thought I had a fairly good grasp of how the static modifier worked. I know that (in laymans terms) a static variable in a function does not \'reset\' acro

3条回答
  •  再見小時候
    2021-01-04 00:57

    1. This is expected.
    2. This is also the case in C++ (and probably others as well).

    You should think of non-static class member functions as if they were just like ordinary functions, but with an implicit $this argument that is automatically provided by the interpreter. (That's exactly how they're implemented in most languages.)

提交回复
热议问题