I. Defining classes
Second, create the object
- Creating objects using the New keyword
-
$obj=new person ();
Third, get the object in the class
Four, const constants
static properties and Static methods
- You can use the static keyword to identify member properties or to identify member methods.
- Here's how to create it:
- Declaring a class property or method as static can be accessed directly without instantiating the class
- Static methods do not need to be called through an object, so the pseudo-variable $this is not available in a static method.
- A static property cannot be accessed by an object through the operator.
- Note: Static members belong to class-owned, so we cannot use $this to refer to static members in static methods, we recommend using the Self keyword to invoke.
- For example:
VI, Inherit public--public property, can freely access private--private property or method only in their own class can use protected--protected properties: Only in their own class and subclasses can call
Prototype Properties--Implementing inheritance
Object-oriented PHP