请问这样写对吗?

来源:3-3 编程练习

慕槑槑

2020-02-05 20:00:05

$score = 70;
$get = '';

//定义匿名函数$com
$com = function($score){
    global $score;
    global $get;
    if($score<=100&&$score>=80){
        $get='优秀';
    }elseif($score<80&&$score>=60){
        $get='合格';
    }elseif($score>=0&&$score<60){
        $get='不及格';
    }else{
        $get='这是啥';
    }
    return $get;
};

//声明函数Comment
function Comment($com,$score){
    $a = $com($score);
    echo "我的成绩是:".$score."我得到的评价是:".$a;
};

//调用Comment函数
Comment($com,$score);


写回答

1回答

guly

2020-02-06

你好,代码逻辑以及运行结果是正确的,祝学习愉快!

0

0 学习 · 4928 问题

查看课程