1. When instantiating a class, you need to use:: Call constant
1 class myclass3{2 Const Const_value = ' A constant VALUE '; 3 }45$obj 3new MyClass3 (); 6 Echo $obj 3:: Const_value;
2. Using static methods or static variables can not be instantiated directly with the class name must use:: Call
1 classMYCLASS42 {3 Public Static $my _static= ' static method variable <br> ';4 5 Public Static functionDoublecolon () {6 EchoSelf::$my _static. "\ n";7 }8 }9 Ten EchoMYCLASS4::$my _static; OneMYCLASS4::d Oublecolon ();
3. Abstract class and abstract method description (1). Abstract classes cannot be instantiated (2). At least one method in an abstract class is declared abstract (3). The abstract method simply declares its invocation method (parameter) and cannot define its specific function implementation. (In simple terms, you can only define the name of an abstract method and not write logic in it) (4). When inheriting an abstract class, the subclass must define all the abstract methods in the parent class (5). When subclasses redefine the parent class abstract method, the declaration level must be greater than or equal to the parent class (6). Subclasses can define optional parameters (7) that do not exist in the parent class. Subordinate knowledge dot curly braces to define the boundary of the variable name "{}"
1 Abstract classAbstractClass2 {3 //forcing subclasses to define these methods4 Abstract protected functionGetValue ();5 Abstract protected functionPrefixvalue ($prefix);6 7 //Common methods (non-abstract methods)8 Public functionPrintOut () {9 Print $this->getvalue (). "\ n";Ten } One } A - classConcreteClass1extendsAbstractClass - { the Public functionGetValue () { - return"Redefining the abstract method of the parent class"; - } - + Public functionPrefixvalue ($prefix,$xinxin="") { - return"{$prefix} redefine the abstract method of the parent class {$xinxinhaha; + } A } at - $obj 5=NewConcreteClass1 (); - Echo $obj 5-GetValue (); - Echo"<br>"; - Echo $obj 5->prefixvalue ("Add a Parameter", "New parameter");
Native PHP uses key points to ignore points!