摘要:后期静态技术绑定,动态匹配成员的调用者<?php class Big { public static $product = '海尔'; public static function getClass(
后期静态技术绑定,动态匹配成员的调用者
<?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		
						
老师总结:其实现在在很多场景下, 类中的需要用到self::的地方, 其实都是可以用static::来替代的, 这样通用性更强一些