php_function

Demo

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php_function</title>
</head>
<body>
<div style="text-align:center;margin:20% 40%;color:pink;background:black">
<?php
error_reporting(E_ALL || ~E_NOTICE);
function level($score){
echo "$score";
echo "<br>"."等级为:";
if ($score >= 100) {
echo "A";
}elseif ($score >= 90) {
echo "B";
}elseif ($score >= 80) {
echo "C";
}
};

$studets = array(
array('name' => 小明,
'score' => 100, ),
array('name' => 小红,
'score' => 90, ),
array('name' => 小绿,
'score' => 80, ),
);

foreach ($studets as $a_student) {
echo "<hr>";

echo $a_student['name']."的成绩".":";
level($a_student['score']);

};

?>
<hr>
</div>

</body>
</html>
文章目录
  1. 1. Demo
  2. 2. Code
|