サマリー:后期靜態(tài)技術綁定,動態(tài)匹配成員的調(diào)用者<?php class Big { public static $product = '海爾'; public static function getClass(
后期靜態(tài)技術綁定,動態(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>';
添削の先生:天蓬老師添削時間:2019-07-05 14:40:52
先生のまとめ:其實現(xiàn)在在很多場景下, 類中的需要用到self::的地方, 其實都是可以用static::來替代的, 這樣通用性更強一些