亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

后期靜態(tài)綁定

Original 2019-07-04 15:53:15 153
abstract:后期靜態(tài)技術(shù)綁定,動態(tài)匹配成員的調(diào)用者<?php class Big {     public static $product = '海爾';     public static function getClass(

后期靜態(tài)技術(shù)綁定,動態(tài)匹配成員的調(diào)用者

<?php

class Big
{
    public static $product = '海爾';
    public static function getClass()
    {
        return __CLASS__;
    }
    public static function getPro()
    {
//        return '一級分類:' .self::getClass() .'<br>品牌:' .self::$product;
        return '一級分類:' .static::getClass() .'<br>品牌:' .static::$product;
    }
}

class Small extends Big
{
    public static $product = '格力';
    public static function getClass()
    {
        return __CLASS__;
    }
}


echo Big::$product .'<hr>';

echo Big::getClass() .'<hr>';

echo Big::getPro() .'<hr>';

echo Small::$product .'<hr>';

echo Small::getClass() .'<hr>';

echo Small::getPro() .'<br>';


Correcting teacher:天蓬老師Correction time:2019-07-05 14:40:52
Teacher's summary:其實(shí)現(xiàn)在在很多場景下, 類中的需要用到self::的地方, 其實(shí)都是可以用static::來替代的, 這樣通用性更強(qiáng)一些

Release Notes

Popular Entries