Home>Article>Backend Development> Sharing of the object-oriented PHP video tutorial of the School of Dynamics

Sharing of the object-oriented PHP video tutorial of the School of Dynamics

黄舟
黄舟 Original
2017-08-30 11:35:51 1163browse

"Power Academy Object-Oriented PHP Video Tutorial" tells the basic concepts of object-oriented and related case practices, so that friends can have a basic understanding of object-oriented and be able to master the abstraction of practical problems into class objects to solve Methods for practical problems and mastering the most important core capabilities of object-oriented.

Sharing of the object-oriented PHP video tutorial of the School of Dynamics

Course playback address://m.sbmmt.com/course/421.html

The teacher’s teaching style:

The teacher’s lectures are vivid, witty, witty, and touching. A vivid metaphor is like the finishing touch, opening the door to wisdom for students; an appropriate humor brings a knowing smile to students, like drinking a glass of mellow wine, giving people aftertaste and nostalgia; a philosopher's aphorisms, cultural references Proverbs are interspersed from time to time in the narration, giving people thinking and warning.

The more difficult point in this video is the abstract class:

For PHP programmers, the most difficult point to master is the application of PHP abstract classes. . As a novice, I am not yet ready to use object-oriented knowledge to program, but in future development, it is inevitable to use classes to encapsulate or use interfaces to develop programs in various modular formats.

In natural language, we understand abstract concepts as a large description of an object, which is a common characteristic for a certain type of object. The same is true in PHP. When we abstract a class, we can indicate the general behavior of the class. This class should be a template, which indicates some behaviors that its sub-methods must implement.

Definition of PHP abstract class application:

abstract class ClassName{ }

Key points of PHP abstract class application:

1. Define some methods, and subclasses must fully implement all methods in this abstraction

 2. Objects cannot be created from abstract classes, its meaning is to be extended

 3. Abstract classes usually have abstract methods, and there are no braces in the methods

PHP abstract class application Key points:

1. Abstract methods do not have to implement specific functions, and are completed by subclasses

2. When a subclass implements a method of an abstract class, the visibility of the subclass must be greater than or equal to Equal to the definition of abstract method

 3. The method of the abstract class can have parameters or be empty

 4. If the abstract method has parameters, then the implementation of the subclass must also have the same parameters Number

PHP abstract class application example:

abstract public function_name(); //注意没有大括号

PHP abstract class rules:

As long as a class contains at least one abstract method, it must be declared as an abstract class

Abstract methods cannot contain function bodies

Inherit subclasses of abstract classes. Those who implement abstract methods must have the same or lower access level as the abstract method

Inheritance A subclass of an abstract class. If it does not implement all abstract methods, then the subclass is also an abstract class

The above is the detailed content of Sharing of the object-oriented PHP video tutorial of the School of Dynamics. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn