开发者

Is it possible to create static variables at runtime in PHP?

开发者_开发知识库

Suppose a class, foo, has one static variable, bar. Is it possible to write PHP code that will create a new static variable, bar2, for the foo class at runtime?


No, it's not possible.

A static variable is, as its name says, allocated statically at compile time. It cannot be allocated during runtime, nor can it be deallocated (e.g.: unset) during runtime either.

Also, static variables are independent of the call stack.

You can read more on Wikipedia.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜