Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<?php
//变量的声明
$php = "博客后台";
//函数的声明
function getPHP(string $php): string
{
return "欢迎进入" . $php;
}
//调用函数
echo getPHP("许小可博客");
echo "<hr>";
//查看变量详细信息
var_dump($php);
echo "<hr>";
//参数不足和js一样用默认参数
function getNum(float $asa, float $sds = 2): float
{
return $asa * $sds;
}
echo getNum(6);
//参数过多时用...rest
$num = function (...$args) {
return array_reduce($args, function ($nums, $tos) {
return $nums + $tos;
}, 0);
};
echo "<hr>";
echo $num(5, 6, 7, 8, 9);