PHP Object-oriented summary

Source: Internet
Author: User

Class

Sum up a few words

:

Classes are abstract and represent a class of things

Ii

object is specific and is a concrete instance of a class

Class is a template for an object

,

An object is an individual instance of a class

Construction method

?

Construction method

No return value

,

It is automatically called

2.

In

PHP 5

In a class can have both

Two forms of construction method

__construct ()

And

Class name

() ,

When two exist at the same time, the first call

__construct (),

Please use after everyone

__construct ()

?

1. $this

It's the address of the object that can be understood.

2.

Which object is used to

$this,

is which object address

3. $this

Cannot be used outside the class

.

Can only be used within a class

Considerations for construction methods

(1)

Once a constructor has been customized, the default

The constructor is overwritten.

,

When you create an object, you will use a custom

constructor function

.

(2)

A class can have only one constructor

. (

Cannot reload

)

of the construction method

8

Point description

:

① constructor method name and class name are the same

(PHP4

Version

), PHP5

Version of the construction method

The name can be the same as the class name, or it can be

__construct () (PS:

Two

_)

PHP Object-oriented summary

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.