“::” 是什么意思?语法是什么意思?
Possible Duplicate:
Reference - What does this symbol mean in PHP?
In PHP what does ::
mean? e.g
Pagination::set_config($config);
Is it analogous to =>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它称为范围解析运算符。
http://php.net/manual/en/keyword.paamayim-nekudotayim.php
It is called Scope Resolution Operator.
http://php.net/manual/en/keyword.paamayim-nekudotayim.php
在 PHP 中,它是范围解析运算符。它用于访问未启动的类的方法和属性。对此表示法明确表示的方法称为静态方法。
此外,您可以使用此表示法相对地遍历扩展类(从您所在的位置)。示例:
在此示例中,doTheMagic 方法覆盖其父级的现有方法,但使用
parent::doTheMagic();
仍可以调用原始方法。In PHP it is the Scope Resolution Operator. It is used to access methods and attributes of uninitiated classes. Methods which are made explicit for this notation are called static methods.
Furthermore you can use this notation to traverse through extended classes relatively (from the position where you are). Example:
In this example the doTheMagic method overwrites the existing method of its parent, but with
parent::doTheMagic();
the original method can be called, nevertheless.这个“::”语法称为范围解析运算符。
它用于引用基类或尚未获得任何实例的类中的函数和变量。
来自 php.net 的示例:
只需阅读示例中的注释即可。有关详细信息,请访问php.net 文章。
This "::"-syntax is called Scope Resolution Operator.
It's used to refer to function and variables in base classes or classes that haven't got any instances yet.
Example from php.net:
Just read the comments in the example. For more information, go to the php.net article.
::
是一个范围解析运算符(最初在 C++ 中如此命名)意味着您将set_config($config)
方法与类关联起来分页
。它是一个静态方法,并且静态方法不能通过其类的对象访问,因为它们与它们的类相关联,而不是与该类的对象相关联。符号->用于访问实例成员。符号
=>
与 PHP 中的关联数组一起使用来访问这些数组的成员。::
is a scope resolution operator (originally named so in C++) means you're associating theset_config($config)
method with the classPagination
. It's a static method and static methods can not be accessed through the objects of it's class, since they are associated with their class rather than the objects of that class.The notation -> is used to access instance members. The notation
=>
is used with associative arrays in PHP to access the members of those arrays.