In OOP-> and: differences between operators

Source: Internet
Author: User
In OOP-& gt; and: operator differences in OOP-> And: What are the differences between operators? Du Niang is not powerful and cannot be found


Reply to discussion (solution)

Variable modified by the static keyword. the external call can only be ::
Static Keyword modifier method, external call-> and: are acceptable, used:, static method cannot operate non-static variables
Now, I want to add it downstairs.

-> Instance call
: It is the reference method of static methods and static properties in the class.


-> Indicates the object member.
: Scope resolution operator. The manual says: functions in the category class or functions and variables in the base class are very useful without declaring any instances. The operator is used in this case.
Although php 5.3 and later have made some restrictions on the usage of:, there is not much difference in general.

1. if a function is defined as static, the direct class name is: method name, and the static attribute is the same.
2. if you only define the function method name (), you need to instantiate the class during access, $ p = new xx (); $ p-> method name ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.