Initial knowledge of PHP object-oriented

Source: Internet
Author: User

Brief introduction:

After the 1970s, object-oriented programming (oriented programming, or OOP) became popular. OOP employs a completely different approach to the development of computer applications. In this approach, the program is not designed around the task to be solved, but rather around the object in question to be solved. The object model is established and the problem is scoped to different objects for processing.

Classes and objects;

Class is a kind of thing description, is abstract, conceptual definition;

An object is an entity that actually exists for that kind of thing, and thus is also called an instance

The process of creating an object is called creating an object, also known as instantiation.

PHP uses the keyword class to define a class. Class naming is usually capitalized with the first character, and then the first character of each word is concatenated in a convenient way to read

Here is a simple style of writing a subordinate sex and behavior:

Class person{//here is the attribute

public $id; Serial number

Public $name; Name

Public $birth; Birthday

Public $sex; Gender

Here is the Act

Public Function SetName ($name) {

$this->name= $name;

}

Public Function GetName () {

$this->name;

}
}

Initial knowledge of PHP object-oriented

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.