10.25 pm Static

Source: Internet
Author: User

1. Static

Static is corresponding to the normal member of the class that was previously made. The members of the class can be divided into two categories, one is ordinary members and the other is static members. The previous write amount is the ordinary member, the ordinary member belongs to the object. A static member belongs to a class, and static is relative to the ordinary member.

Definition of static Member:

// static//Ordinary members are objects belonging to//static members//static members are belong to the class//keyword: static//self keyword: class inside the class//In a static method cannot call ordinary members//ordinary method inside can call static members /* class fenbi{public    $length;//The length of the chalk, defined as a normal member. public    static $color;//The Color of the chalk, defined as a static member. Static defines the statically defined keyword.        static function Show ()    {        echo "Chalk color is:". Self:: $color;//self to the class name Fenbi can also, self in the class represents the class, this is the object inside the class.    }    function Xianshi ()    {        echo "shows:". Self:: $color;    }} $f = new Fenbi ();//Create an object $f->length;//use the object to call the ordinary member Fenbi:: $color = "Red";
Fenbi::show ();//Call static methods without Fenbi:: $color;//Because static members belong to classes, use the class name to call static members $f->xianshi (); */

10.25 pm Static

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.