In php: how to use it?

Source: Internet
Author: User
In the subclass, the parent: method () is used to access the methods in the parent class, but: is used to access static things. If this method is not static, isn't that self-contradictory? Why can I access it? In the subclass, the parent: method () is used to access the methods in the parent class, but: is used to access static things. If this method is not static, isn't that self-contradictory? Why can I access it?

Reply content:

In the subclass, the parent: method () is used to access the methods in the parent class, but: is used to access static things. If this method is not static, isn't that self-contradictory? Why can I access it?

You can use classname: methodname () to directly call common methods in the class at any location of the PHP file. I personally think this is because
The objects stored in the heap area of the memory only store the object attributes. The object methods are stored in the code area and are member methods of the class, if $ this is not included in the member method of the class called by the object, there is no obvious difference between this method and the static method stored in the static data area. In this case, the object's member method is not significantly different from the object's static method.
Does not change with the calling object.
In addition, the member methods are defined in the class, that is, the relationship between father and son. The difference is that they are born by their wives (static methods ), the other is born with another wife (member method). The son of another wife is called Dad. The private son knows the situation one day (no $ this ). The two will be called Dad.
Now you can use classname: methodname ()

Copy C ++.

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.