标签:php var_dump protect ted ati fun code The protected
<?php
class Father{
protected static $name = "大头";
public static function father_self(){
echo self::$name."\n";
}
public static function father_static(){
echo static::$name."\n";
}
public static function getInstance_self(){
return new self();
}
public static function getInstance_static(){
return new static();
}
}
class Son extends Father{
protected static $name = "小头";
}
Son::father_self(); //大头
echo "<br>";
Son::father_static(); //小头
echo "<br>";
var_dump(Son::getInstance_self()); //Father
echo "<br>";
var_dump(Son::getInstance_static()); //Son
static::、self::、new self()、new static()
标签:php var_dump protect ted ati fun code The protected
原文地址:https://www.cnblogs.com/jingdr/p/14779435.html