Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:
static
关键字
<?php
//使用self关键字测试
namespace self_test;
class cBase{
public static $val = 'cBase';
public static function ret(){
return self::$val;
}
}
class cSub extends cBase{
public static $val = 'cSub';
}
echo (new cSub)->ret();
echo '<hr>';
//使用static关键字测试
namespace static_test;
class cBase{
public static $val = 'cBase';
public static function ret(){
return static::$val;
}
}
class cSub extends cBase{
public static $val = 'cSub';
}
echo (new cSub)->ret();