PHP object-oriented programming (video tutorial ). Object-oriented programming (ObjectOrientedProgramming, OOP, object-oriented programming) is a computer programming architecture, one of the basic principles of OOP is that a computer program is a computer Programming architecture composed of a single program capable of object-oriented Programming (Object Oriented Programming, OOP, object-oriented Programming, one basic principle of OOP is that a computer program is composed of a single unit or object that can act as a subroutine. OOP achieves three objectives of Software Engineering: reusability, flexibility, and scalability. To achieve the overall operation, each object can receive, process, and send information to other objects. Object-oriented has always been a hot topic in the field of software development. first, object-oriented is in line with the general rules of human beings. Second, the use of the object-oriented method can make all parts of the system perform their duties and do their best. Open a door for programmers to make their programming code simpler, easier to maintain, and more reusable. Some people say that PHP is not a real object-oriented language. this is a fact. PHP is a hybrid language. you can use OOP or traditional procedural programming. However, for large projects, you may need to use pure OOP in PHP to declare classes and use only objects and classes in your project. I will not talk much about this concept first, because many of my friends are far away from object-oriented programming because they cannot understand it when they come into contact with the object-oriented concept, so they don't want to learn it anymore. After reading the entire content, you can understand the concept.
First go to the video tutorial:
BkJia video tutorial 17: PHP object-oriented development (1)
BkJia video tutorial 18: PHP object-oriented development (2)
BkJia video tutorial 19: PHP object-oriented development (3)
BkJia video tutorial 20: PHP object-oriented development (4)
BkJia video tutorial 21: PHP object-oriented development (5)
BkJia video tutorial 22: PHP object-oriented development (6)
BkJia video tutorial 23: PHP object-oriented development (7)
BkJia video tutorial 24: PHP object-oriented development (8)
BkJia video tutorial 25: PHP object-oriented development (9)
Instance:
BkJia video tutorial 26: create your own PHP + MYSQL class
More
========================================================== ====================
Article Directory:
1. object-oriented concepts
2. what is a class, what is an object, and the relationship between a class and an object
3. What is object-oriented programming?
4. how to abstract a class?
5. how to instantiate an object?
6. how to use members in an object?
7. special reference to the use of "$ this"
8. constructor and constructor
9. encapsulation
10. _ set (), _ get (), _ isset (), and _ unset ()
11. class inheritance
12. Application of polymorphism
13. reload the new method
14. access type
15. use of static members
16. Application of final keywords
17. _ toString () method
18. Clone object
19. _ call handle call errors
20. automatically load the class
21. serialize objects
22. abstract methods and abstract classes
23. php5 interface technology
========================================================== ====================
2. what is a class, what is an object, and the relationship between a class and an object
Class Concept: A class is a set of objects with the same attributes and services. It provides a unified abstract description for all objects belonging to this class, which includes two main parts: attribute and service. In an object-oriented programming language, a class is an independent program unit. it should have a class name and contain two main parts: attribute description and service description.
Object: an object is an entity used to describe objective things in a system. it is a basic unit of a system. An object consists of a group of attributes and a group of services that operate on these attributes. From a more abstract point of view, an object is an abstraction of some things in the problem domain or implementation domain. it reflects the information that the things need to be stored in the system and its role; it is the encapsulation body of a set of attributes and a group of services that have the right to operate on these attributes. The objective world is composed of links between objects. The relationship between a class and an object is like the relationship between a mold and a casting. The instantiation result of a class is an object, and the abstraction of a class object is a class. Class describes a group of objects with the same features (attributes) and the same behavior (methods. The above is probably their definition. maybe you are new to object-oriented friends and should not be confused by concepts. here is an example for you, if you want to buy several assembled PC machines in Zhongguancun, what do you do when you get there? are the installation engineers sitting with you, based on the information you provide, complete an installation configuration sheet with you. this configuration sheet can be considered a class, and it is a piece of paper, however, it records the information of the PC machine you want to buy. if you use this configuration item to buy 10 machines, the 10 machines are all composed of this configuration list, therefore, these 10 machines are of the same type or category. So what is an object? the instantiation result of the class is an object. the machine that is configured (instantiated) with this configuration sheet is an object, which is an object that we can operate on. There are 10 machines and sub-databases, 10 objects. Each sub-machine is independent and can only indicate that they are in the same category. any action on one of the sub-machines will not affect the other nine machines, but I modify the class, that is to say, if one or fewer accessories are added to the configuration list, the Nine hosts that are installed are changed. this is the relationship between class objects (the instantiation result of the class is the object ).
3. What is object-oriented programming?
If you want to build a computer classroom, you must first have a room with N computers, N tables, N chairs, and whiteboards, projector, etc. What are these? we just talked about it. this is an object. we can see entities. we can say that the units in this computer classroom are physical objects, they make up the computer classroom together. so what is the relationship between our program and the object-oriented system? Developing a system program is similar to building a computer classroom. you Abstract each independent function module into a class to form an object, which consists of multiple objects, these objects can receive information, process data, and send information to other objects. It constitutes an object-oriented program.
4. how to abstract a class?
As mentioned above, the unit of the object-oriented program is the object, but the object is instantiated through the class, so the first thing we need to do is how to declare the class, it is easy to create a class. you only need to master the basic program syntax and definition rules. where is the difficulty? How many classes are used in a project, how many objects are used, where classes are to be defined, what kind of classes are defined, how many objects are produced by this class instance, and how many attributes are contained in the class, how many methods are there, etc. This requires the reader to analyze and design the actual problems in actual development. Class definition:
Class name {
}
Use a keyword class and a class name you want and a pair of braces. The structure of this class is defined. you only need to write code in it, but what is written in it? What can I write? How to write is complete
Class? As mentioned above, the class is used to let it instance out of objects for us to use, so we need to know what kind of object you want, as we mentioned above, what is written on an installation configuration sheet is what you have installed on the machine. For example, if a person is an object, how do you recommend a person you are optimistic about to your leadership? Of course, the more detailed the better: first, you will introduce the name, gender, age, height, weight, phone number, home address, and so on. Then, you will introduce what this person can do. he can drive, speak English, and use a computer. As long as you have a little introduction, others will have a little understanding of this person. this is our description of a person. now, let's sum up that all objects are similar to class descriptions, from the description above, we can see that a class is defined in two parts: static description and dynamic description, static descriptions are what we call attributes, such as the name, gender, age, height, weight, phone number, home address, and so on. It is also the function of the person. for example, the person can drive, speak English, and use a computer.
Object Oriented Programming (OOP) is a computer Programming architecture. one of the basic principles of OOP is that computer programs are played by a single program...