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)一些