The object-oriented basis of PHP OOP

Source: Internet
Author: User
Tags abstract definition php oop

What is object-oriented

Process oriented

It's like you're an employee of the company, and today there's a job to assemble a bunch of computers at the company. Then you'll start picking

Buy, bargain, transport back to the company, start assembling, wiring network, commissioning the machine, complete. In other words, process-oriented

Is the embodiment of the realization, the details are clear.

Object oriented

It's like you're the president of the company, and you assign a job to an employee to assemble a bunch of computers. Complete. That is

said that object-oriented is abstract execution, specifically by the staff to complete. And in detail, the president doesn't need to go

Consider. It is obvious that companies with high levels of management can coordinate their operations without managing high-level public

Division, only some of the specific implementation of the functions of employees, will be a mess.

Two Features of OOP OOP oop oop

Packaging

Hides the properties and implementation details of the object, exposes the interface only externally, controls the access level of the Read and modified properties in the program

Abstract data and behavior (or function) to form an organic whole, that is, the data and

The source code for manipulating data is organically combined to form "classes" where data and functions are members of the class.

Inherited

Inheritance is the mechanism of getting one or more classes from a base class.

A class that inherits from another class is called a subclass of that class. This relationship is usually likened to the father and the child. Sub-class will continue to

The attributes of the parent class. These attributes are made up of properties and methods. Subclasses can add new functionality outside of the parent class, so subclasses Also

is called the "extension" of the parent class.

Polymorphic

Polymorphism refers to the ability of OOP to redefine or change the nature or behavior of a class based on the context of the class being used, or

Many different implementations of the port are polymorphic. Different subclass objects are treated as parent classes, and different subclasses can be masked

The differences between objects, write generic code, and make generic programming to suit the changing needs.

Three The key OOP OOP oop OOP concept

Classes (Class class Class)

A class is a definition of an object. It contains information about how the object acts, including its name, method, properties

and events. In fact, it is not an object in itself, because it does not exist in memory. When the code that references the class is run, the class's

A new instance, the object, is created in memory. Although there is only one class, it can be created in memory from this class

Multiple objects of the same type.

Objects (Object Object Object object)

An object is a thing, an entity, a noun that can get something that can be imagined to have its own identity for any

Things. An object is an instantiation of a class. Some objects are live, some objects are not.

such as this car, this man, this House, this table, this plant, this check, this raincoat. Almost

In other words: Everything is the object.

For example: A class is an abstract definition of an object, and plainly, if the object is a computer, the class can create many objects,

Class can generate a lot of computers, and then white, the class can be used as a computer production plant, can generate a lot of computers.

Field (filed filed filed filed)

A field is a property that describes an aspect of a class that is very similar to a typical PHP variable, but with some subtle

The difference.

For example: Computer brands, computer models and other features.

Properties (attribute attribute attribute attribute)

Use methods to access and manipulate fields, on the one hand, to protect fields while also allowing access to public fields like access

Data.

For example: Get a computer brand, set up a computer brand and other operations.

Methods (method)

Methods are very similar to functions, except that methods are used to define the behavior of a class. As with functions, the method can accept the output

into a parameter, you can return a value to the caller.

For example: Open the computer, enter text, run the program.


The object-oriented basis of PHP OOP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.