学号:A00287
姓名:尹浩伟
2017-08-16 打卡
今天打卡内容是流程控制和数组相关知识。
[HTML] 纯文本查看 复制代码 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>学生成绩管理</title>
</head>
<body>
<form action="dmeo07.php" method="post" >
<caption><h3 align="center">成绩管理</h3></caption>
<div id="grade" align="center">
<p>请输入您的成绩:<input type="text" name="gradeText" id="gradeText" value="<?php echo (isset($_POST['isSubmit']) && $_POST['isSubmit'] == 'ok') ? $_POST['gradeText'] : '' ?>" /> <input type="submit" value="确定" /></p>
<p><input type="hidden" name="isSubmit" value="ok" /></p>
</div>
</form>
</body>
</html>
[PHP] 纯文本查看 复制代码 <?php
/**
*
* @authors yhw-miracle ([email]yhw_software@qq.com[/email])
* @date 2017-08-15 22:16:26
*/
header("content-type:text/html;charset=utf-8");
// 成绩管理
include_once("demo01.html");
if(isset($_POST['isSubmit']) && $_POST['isSubmit'] == "ok") {
if(!empty($_POST['gradeText'])) {
$grade = $_POST['gradeText'];
if($grade <= 100 && $grade >= 90) {
echo "<p align=\"center\">恭喜你,您的等级为 A,继续保持呀!</p>";
} elseif($grade >= 80) {
echo "<p align=\"center\">也不错哦,您的等级为 B,继续加油呀!</p>";
} elseif($grade >= 70) {
echo "<p align=\"center\">哈哈,您的等级为 C,再接再厉!</p>";
} elseif($grade >= 60) {
echo "<p align=\"center\">好好复习,争取下次考好,您的等级为 D!</p>";
} elseif($grade >= 0) {
echo "<p align=\"center\">一次失败不代表什么,下次加油哦,您的等级为 E!</p>";
} else {
echo "<p align=\"center\">对不起,您输入的成绩非法!</p>";
}
}
}
// 九九乘法表,for 循环
for ($i = 1; $i <= 9; $i ++) {
for ($j = 1; $j < $i; $j ++) {
echo "$j * $i = ".($j*$i)." ";
}
echo "<br />";
}
// while 循环
$i = 0;
$sum1 = 0;
$sum2 = 0;
$sum = 0;
while ( $i<= 100) {
if($i % 2 == 0) {
$sum1 += $i;
} else {
$sum2 += $i;
}
$sum += $i;
$i ++;
}
echo "奇数项和为:".$sum1." 偶数项和为:".$sum2." 总和为:".$sum;
// 数组
$student01 = [
'name' => 'yhw',
'age' => 18,
'birthday' => '07-01',
'studying' => 'php',
'hobby' => [
'bastketball' => true,
'game' => true,
'coding' => true,
'sleep' => false
],
'school' => 'hfnu'
];
echo "<pre>";
var_dump($student01);
print_r($student01);
echo "</pre>";
foreach ($student01 as $k => $v) {
if($k == 'hobby') {
foreach ($student01['hobby'] as $k1 => $v1) {
if($v1) {
echo "student01 擅长 $k1 <br />";
} else {
echo "student01 不擅长 $k1 <br />";
}
}
} else {
echo "student01 的 $k 值为 $v <br />";
}
}
|