1. Three main features of object-oriented: encapsulation, inheritance, polymorphism, (abstract (extended))
2, 00A: Analysis, OOD: Design, OOP: programming.
3. Encapsulation: Information concealment, encapsulation, all functions and methods, properties and behaviors in the class are also encapsulated. Three access modifiers public, protected, private are also encapsulated.
4, public common who can use, can also be modified; protected protected only by themselves and descendants can be used and modified; private only own can be used and modified;
5. Inheritance: Extend the contents of the parent class, note that only public and protected-modified content can be inherited, and the private adornment cannot inherit the keyword: extends,
Inheritance in PHP is a single inheritance, that is, there are only 1 class names behind extends, but 1 classes can have an infinite number of subclasses, and the subclasses and the parent classes can only be between 2 classes that have an inheritance relationship.
6. A method that appears in a subclass with the same name as the parent class, which is called rewriting, is a redefinition of the behavior. Overrides can only occur between classes that have an inheritance relationship, which is overridden by the same method name, and has no relation to the parameter.
When overridden, the access modifier can be accessed in a range that is not lower than the access modifier in the parent class. The method for the private adornment cannot be overridden.
code example:
Class zixingche{
protected $name = ' bike ';
protected $gulu = 2;
protected $yanse;
Public Function Qiche () {
echo ' can ride ';
Public Function Shache () {
echo ' can brake brake ';
Public Function Jieshao () {
echo ' this is '. $this->name;
Echo ', ';
$this->qiche ();
Echo ', ';
$this->shache ();
}
}
Class Zhediezixingche extends zixingche{
Public Function __construct ($name = ' collapsed from Driving ') {
$this->name = $name;
Public Function Zhedie () {
echo $this->name. ' can be folded ';
}
Public function Jieshao () {
Parent::jieshao ();
Echo ', ';
$this->zhedie ();
}
}
Three main features of PHP object-oriented