正如标题所说,我似乎无法看到公共静态与普通旧静态之间的差异。即
public static function visitorUserCreate( $data ) {}和
static function visitorUserCreate( $data ) {}两者似乎都是公开的,如果它们是默认声明公开的重点是什么?
As the title says i cannot seem to see what the difference is between a public static and just a plain old static.. ie
public static function visitorUserCreate( $data ) {}and
static function visitorUserCreate( $data ) {}Both appear to be public, if they are what is the point in declaring public if it is by default?
最满意答案
从静态关键字的PHP手册文档 :
为了与PHP 4兼容,如果未使用可见性声明,则将属性或方法视为声明为public。
回答你的问题:
两者似乎都是公开的,如果它们是默认声明公开的重点是什么?
没有。 宣布公开的目的是为了提高可读性。 在编译器级别没有区别,但是通常很好的设计来声明它。
From the PHP manual documentation for Static Keywords:
For compatibility with PHP 4, if no visibility declaration is used, then the property or method will be treated as if it was declared as public.
To answer your question:
Both appear to be public, if they are what is the point in declaring public if it is by default?
None. The point of declaring public is for readability. There is no difference at compiler level, however it's usually good design to declare it.
更多推荐
发布评论