abstrak:<?php //利用后期靜態(tài)綁定技術(shù),實(shí)現(xiàn)在父類(lèi)調(diào)用子類(lèi)中重寫(xiě)的靜態(tài)成員 //創(chuàng)建父類(lèi) class Father { public static $price=5000; public static function getClass()
<?php //利用后期靜態(tài)綁定技術(shù),實(shí)現(xiàn)在父類(lèi)調(diào)用子類(lèi)中重寫(xiě)的靜態(tài)成員 //創(chuàng)建父類(lèi) class Father { public static $price=5000; public static function getClass() { return __CLASS__; } public static function getPrice() { return static::getClass().':'.static::$price; } } //創(chuàng)建子類(lèi) class Son extends Father { public static $price=8000; public static function getClass() { return __CLASS__; } } echo Father::$price,'<br>'; echo Father::getClass(),'<br>'; echo Son::$price,'<br>'; echo Son::getClass(),'<br>'; echo Son::getPrice();
Guru membetulkan:查無(wú)此人Masa pembetulan:2019-04-16 09:39:00
Rumusan guru:完成的不錯(cuò)。學(xué)完php的類(lèi),已經(jīng)算入門(mén)了。要堅(jiān)持,繼續(xù)加油。