Object
In object-oriented programming, objects are a very important core concept. From the point of view of program design, object is the basic unit of object-oriented approach, and also an independent entity describing objective things. The process of creating an object is called instantiation, and when an object is created, it contains 3 aspects of the attribute: the handle, the property, and the method of the object.
· handle to the object: used to distinguish between different objects. When an object is created, the object acquires a piece of storage space, and the address of the storage space is the object's identity, which is the handle to the object.
· Properties: A data item used to describe the static characteristics of an object (structural properties). such as describing a person's name, gender, birthday and social Security number, etc. are attributes.
· method: A series of actions used to describe the object's dynamic characteristics (behavioral characteristics). As everyone has the behavioral characteristics of working, learning and speaking.
If you want to use a class, you first use the keyword new to create an instantiated object of that class, with the syntax in the following format:
For example, if you want to use the Dabing class, you first need to use the keyword new to create an instantiated object of that class, with the following code:
$obj=newDabing(); //创建对象obj |
When this object is created, it exists in the lifetime of the program, and when the program finishes or the program is cleared, the object is destroyed. PHP can implicitly destroy objects, programmers do not have to worry about the end of the use of an object, forget to release the associated memory resources.
If you want to create a new and unique object, you can use the reference symbol "&", which has the following syntax format:
Classes and objects: creating objects