Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:
<?php// 接口
interface iDbd
{
const JS = '计算加减乘除';
public static function m1($a, $b);
public static function m2($a, $b);
public static function m3($a, $b);
public static function m4($a, $b);
}
class DD_Db implements iDbd
{
public static function m1($a, $b)
{
return "$a + $b =".($a+$b);
}
public static function m2($a, $b)
{
return "$a - $b =".($a - $b);
}
public static function m3($a, $b)
{
return "$a X $b =".($a * $b);
}
public static function m4($a, $b)
{
return "$a / $b =".($a / $b);
}
}
echo iDbd::JS, '<br>';
echo DD_Db::m1(1,2),'<br>';
echo DD_Db::m2(3,2),'<br>';
echo DD_Db::m3(2,2),'<br>';
echo DD_Db::m4(10,2),'<br>';
// 抽象类
abstract class Abc
{
public static function m1($a)
{
return $a;
}
abstract public function __construct();
}
class Aac extends Abc
{
public function __construct(...$b)
{
echo print_r($b,true),'<br>';
}
}
new Aac('aa','cc','dd');
echo Aac::m1(5);
//在抽象类中可以写公共不抽象方法,但是在接口中不能写不抽象类方法,
![](https://img.php.cn/upload/image/583/156/446/1618395069697127.png)