Object-oriented object concept is the core of object-oriented technology. The things we face in the world are objects, such as computers, televisions, bicycles, and so on. In object-oriented program design, object is a whole composed of information and the description of information processing, and it is an abstraction to the real world.
The main three attributes of an object
Object behavior: You can apply those actions to the object, turn on the light, turn off the light is behavior.
The shape of the object: When applied to those methods is how the object responds, color, size, and shape.
Object representation: The representation of an object is equivalent to an identity card, which distinguishes between the same behavior and the state.
Object-oriented model
Object-oriented concepts:
OOP (object-oriented programming) it makes its code simpler and easier to maintain and more resilient
What is a class:
A class is a collection of objects with the same attributes and services, such as people, books, ships, cars all belong to the class, he made a unified abstract description of objects belonging to the class, in programming language class is a separate program, it should have a class name including attribute description and service two parts.
What is an object:
An object is an entity that describes an objective event in a system, and he is a basic unit of the system. * Data and code are bundled in an entity *, an object consists of a set of properties and a set of behaviors that operate on the set of attributes.
From an abstract point of view, an object is an abstraction of something in the problem domain or implementation domain. He reflects the information and role that the thing holds in the system: it is a set of properties and a package that has permission to operate on these properties. The objective world is made up of the relationship between objects and objects.
Relationships between classes and objects:
The relationship between the class and the object is like the relationship between the mold and the casting, the result of the strength of the class is the object, and the abstraction of the object is the class, and the class describes the set of objects with the same attributes (attributes) and the same behavior.
Classes and properties and methods
Define class syntax format in PHP:
class classname [optional attribute]{
Public $property [=value];///To declare a common identity and give a variable variable can also be assigned a value
member functions in Methods of function functionname (args) {//Class
Code} ...
Method of a class (member function)
}
Build object (Instantiation of Class): $ object Name =new classname ();
Using the properties of an object
In a class, you can access a special pointer $this when the variable is set or accessed through an action in the class, referenced using $this->name.