PHP static properties and static method learning notes

Source: Internet
Author: User

The static modifier can be used before the property and the method to make it an attribute and a static method.

Access to static properties is accessed using classes such as human:: $head

1. After the class is generated, the static property is already present and no dependent objects are required to access

2. The class has only one in memory, so there is only one static property.

Common method, stored in the class, only one copy

Static method is also stored in the class, only one copy.

The difference is that the common method needs to use formation to mobilize, need to bind $this, must have the object, with the object transfer.

The static method, which does not belong to the object, belongs to the class, so there is no need to use $this to bind, the same class name can be called.

PHP static properties and static method learning notes

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.