The first time I came into contact with the object-oriented concept was that I learned JAVA after I had just finished the C language during my college years. Since C does not have the object-oriented concept, it suddenly emerged in JAVA, although the teacher did not bother Class A Lot Of image examples to illustrate how the object is, but it still sounds like roaming in the cloud. ObjectOrientedProgamming (OOP) is a computer programming architecture. One of the basic principles of OOP is: the concept of a computer program that allows me to get started with object-oriented for the first time was that I learned JAVA after I had just finished the C language during college. Since C does not have the object-oriented concept, it suddenly emerged in JAVA, although the teacher did not bother Class A Lot Of image examples to illustrate how the object is, but it still sounds like roaming in the cloud.
Face Image ProgrammingObject Oriented Progamming (OOP) is a computer programming architecture. One basic principle of OOP is that a computer program is composed of a single Object that can act as a subroutine, to achieve the overall operation, each object can receive information, process data, and send information to other objects. object-Oriented Programming has achieved three goals of Software Engineering: reusability, flexibility, and scalability, making the coding simpler, easier to maintain, and more reusable. the role of object-oriented programming has been fully realized in JAVA. Since the release of the official PHP5 version, PHP has introduced all the object-oriented mechanisms.
There are a lot of resources for learning PHP object-oriented programming, but they are all abstract. Therefore, I will comprehensively explore PHP object-oriented in combination with a classic game, Wulin Three Kingdoms. The Three Kingdoms of Wulin-a large-scale strategy-war web game with Wei, Shu, and Wu as the background. In the Three Kingdoms of Wulin, you can play the role of a zhouch, own a city of your own, build a city, develop an army, launch a war, and unite the world.
Because the Three Kingdoms of Wulin are based on the Three Kingdoms, they are familiar with all the Three Kingdoms, so they are easier to understand during the discussion. Even so, it is still not enough to understand or understand the learning process. You must test it with an instance. You may have unexpected gains.
Here, I would like to remind you that in order to facilitate learning, except for special instructions, otherwise there is no association between some codes. In addition, different codes are often used for the same thing. In addition, we do not need to check the attribute numbers of each type of troops.
PHP class declaration and Creation
The class declaration is very simple, similar to the function declaration. You only need to add a custom category name and a pair of curly braces after a keyword class. Based on your needs, you may also add some modifier class keywords, such as abstract and final, before the class keywords.
The Declaration format of the class is as follows:
[Modifier class keywords] class name {
Class member:
}
Declare a country class:
Class Country {// declare a Country class // declare a Country-related member attribute -- Country name, and a description method $ countryname; // The member attribute of the class, used to store country names, such as Wei Guo function