Declaration and instantiation of a class

Source: Internet
Author: User
Declaring methods

(modifier keyword) class name {

Member properties

Member Methods

}

Attention

1. A file only holds a class, the file name contains the class name, so the advantage of naming is convenient for later program automatic loading

2. The members of the class belong to this class

3. The member attributes should have the Modifier keyword, do not know what to add the words with Var

Instantiating an Object

$ object Name =new class name

Creating an object is allocating a space in memory

Out-of-object member access

Access by object

$ object Name->$ Property name =

$ object Name->$ method name ()

Access to members in an object

is to access other methods and member properties in the object's methods in an internal method of an object

Use the $this keyword to invoke the object of this method, which is equivalent to the first person "I"

$this cannot be accessed outside the class

The above describes the declaration and instantiation of the class, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.