PHP 中的静态属性

发布于 2024-08-12 09:52:45 字数 51 浏览 1 评论 0原文

静态属性何时初始化,据我所知,其他成员属性是在创建对象时初始化的。

谢谢

When are static properties initialized, as I know other member properties are initialized when object is created.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

行雁书 2024-08-19 09:52:45

将类属性或方法声明为静态可以使它们无需实例化类即可访问。声明为静态的属性无法使用实例化的类对象进行访问(尽管静态方法可以)。

/ http://php.net/manual/en/language.oop5.static .php

因此,它们在声明后就可用。

Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static can not be accessed with an instantiated class object (though a static method can).

/ http://php.net/manual/en/language.oop5.static.php

So, they are available after they have been declared.

北恋 2024-08-19 09:52:45

静态属性?你的意思是静态变量还是静态方法?

无论哪种方式,它们都会在解析脚本或定义类时初始化。

Static properties? Do you mean static variables or methods?

Either way, they are initialized when the script is parsed, or the class is defined.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文