Classes and objects: Classes and object definitions

Source: Internet
Author: User

In the process of learning PHP, starting from the Zero Foundation, from the first book to understand, to the second book of the impression, and then to the third book operation Simple statement ... I can't remember how many books I've seen. However, in the application, each time to some key points of knowledge and core technology, the definition and usage will have a vague feeling, so deliberately the more important knowledge points as a network note, so easy to often turn over to review.

Process-oriented definition:

"Process-oriented" is an event-centric programming idea, which is to analyze the steps required to solve the problem, and then use the function to implement these steps gradually, when used will be called one by one.

The process-oriented programming approach focuses on the use of data, in the process of programming through a flowchart to assist the program design, and then use structured programming statements to write programs. Process-oriented program design logic structure is very rigorous, data management is a bit confusing. When the program size is not very large, process-oriented programming because of the process of clear, can be in accordance with the module and function of a good way to organize the program structure.

Object-oriented definition:

Object-oriented breaks down the problem-forming transactions into objects that are not intended to complete a single step, but rather to describe the behavior of a transaction throughout a problem-solving step.

Object-oriented programming is based on process-oriented programming, and its important change is that in object-oriented programming, the program will be designed around the manipulated data, not the operation itself. Object-oriented programming takes class as the basic unit of construction program, which has the characteristics of encapsulation, data abstraction, inheritance, polymorphism and so on.

Class:

In object-oriented programming, a class is a very important core concept. From a programming standpoint, a class is a collection of objects with the same semantic attributes. The so-called semantic nature of the same means:

objects in the same class have the same properties;
objects in the same class have the same method;
objects in the same class adhere to the same semantic rules.

In PHP we use the keyword class to create a new class with the first letter of the class name capitalized. Class members include member variables and member methods, and the syntax for defining classes is as follows:

class 类名称{    //成员变量列表    function成员方法1([参数1,参数2,……]){    //成员方法1的具体实现    }    function成员方法2([参数1,参数2,……]){    //成员方法2的具体实现    }   //其他成员方法}

Use the keyword class below to create a dabing class with the following code:

classDabing {   //成员属性…   //成员方法… }

This line of code only implements a class structure called "dabing", and nothing else is implemented.

Classes and objects: Classes and object definitions

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.