Thisselfparent in php

Source: Internet
Author: User
Thisselfparent in php
  • This is a pointer to an object instance. it is determined to point to it during instantiation;
  • Self is a reference to the class itself and is generally used to point to static variables and constants in the class;
  • Parent is a reference to the parent class. it is generally used to call the constructor of the parent class.
  • You must use self to call static members in a class (generally with the keyword static. To use self to call static variables, you must use: (domain operator number ).

    Static keywords describe that a member is static and can only be accessed using the class name and self:. The value can be changed. you need to add the $ symbol when defining the member. you can use the modifier such as private.

    Const is used for defining constants of class members. it can only be accessed by class name and self:. The value cannot be changed. Generally, the variable name must be in upper case during definition, and no modifier such as private can be added.

    Private static $ count = 0; // define a static attribute const VERSION = 2.0; // define a constant
    Reference URL:

    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.