Php object-oriented notes (2)

Source: Internet
Author: User
Tags php template
1. Static variables and methods? Use the keyword static ?, Static class methods do not need to instantiate objects. They can be called using: symbol; static methods and properties can only access static methods and properties; Use self: keywords to access static members of the current class; all instances of a class share the static attributes of the class. Static Methods call non-static methods

1. Static variables and methods? Use the keyword static ?, Static class methods do not need to instantiate objects. They can be called using: symbol; static methods and properties can only access static methods and properties; Use self: keywords to access static members of the current class; all instances of a class share the static attributes of the class. Static Methods call non-static methods

1. Static variables and methods? Use the keyword static ?, Objects do not need to be instantiated for static class methods. They are called using the: symbol;

Static methods and attributes can only access static methods and attributes;

Use self: keyword to access static members of the current class;

All instances of a class share the static attributes of the class;

When a static method calls a non-static method, the system automatically converts the method to a static method;

---- The single-piece mode in php can be implemented through static methods

2. What are the final classes and methods? ? The final class cannot be inherited, and the final method cannot be overwritten;

3. Constant? Classes use cons to modify constant names. Generally, uppercase is used, and multiple letters are separated;

4. abstract classes and abstract methods are modified using abstract,

Abstract classes cannot be instantiated;

Abstract METHODS only have method declaration, and there is no method implementation content; abstract methods are not used {}; End

In a class, the class must be an abstract class as long as there is an abstract method;

If a subclass inherits the abstract class and overwrites all the methods of the abstract class, the subclass can be instantiated;

Abstract classes inherit abstract classes. abstract methods cannot be overwritten;

---- Php template mode can be implemented through abstract classes;

Original article address: php object-oriented note (2). Thank you for sharing it.

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.