update
This commit is contained in:
parent
5d8e0d8f01
commit
d22843d66a
|
@ -77,3 +77,4 @@ fabric.properties
|
|||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
/images/
|
||||
|
|
15
10.test1.php
15
10.test1.php
|
@ -1 +1,16 @@
|
|||
<?php
|
||||
//date_default_timezone_set("Asia/Shanghai");
|
||||
echo date('H:i:s') . "<br>";
|
||||
print_r(getdate()) ;
|
||||
echo time() . "<br>";
|
||||
$currentTime = mktime(12, 0, 0, 1, 1, 2024);
|
||||
echo '给定时间戳对应的日期:' . date("Y-m-d", $currentTime) . "<br>";
|
||||
echo '给定时间戳对应的时间:' . date("H:i:s", $currentTime) . "<br>";
|
||||
echo 'Now:' . date('Y-m-d', time());
|
||||
echo 'Next week:' . date('Y-m-d', time() + (7 * 24 * 60 * 60)) . "<br>";
|
||||
var_dump(checkdate(12,24,2024));
|
||||
echo '<br>';
|
||||
echo strtotime('now').'<br>';
|
||||
echo strtotime('21 May 2009').'<br>';
|
||||
echo strtotime('+3 day').'<br>';
|
||||
echo date('Y-m-d',strtotime('last sunday'));
|
12
10.test2.php
12
10.test2.php
|
@ -1 +1,13 @@
|
|||
<?php
|
||||
/*
|
||||
* 显示周几(不同国家的语言设定),原教程中的strftime在高php版本上弃用
|
||||
*/
|
||||
$dateTime = new DateTime();
|
||||
$formattedDate = IntlDateFormatter::formatObject($dateTime, 'EEEE','en_US');
|
||||
echo $formattedDate;
|
||||
$formattedDate = IntlDateFormatter::formatObject($dateTime, 'EEEE','zh_CN');
|
||||
echo $formattedDate;
|
||||
$formattedDate = IntlDateFormatter::formatObject($dateTime, 'EEEE','zh_HK');
|
||||
echo $formattedDate;
|
||||
$formattedDate = IntlDateFormatter::formatObject($dateTime, 'EEEE','ja_JP');
|
||||
echo $formattedDate;
|
22
10.test3.php
22
10.test3.php
|
@ -1 +1,23 @@
|
|||
<?php
|
||||
$start_run_time = run_time();
|
||||
$time1 = date("Y-m-d H:i:s");
|
||||
$time2 = "2008-2-3 16:30:00";
|
||||
if (strtotime($time1) > strtotime($time2)) {
|
||||
echo 'time1晚于time2';
|
||||
} else if (strtotime($time1) < strtotime($time2)) {
|
||||
echo 'time1早于time2';
|
||||
} else {
|
||||
echo 'time1等于time2';
|
||||
}
|
||||
$currentTime = time();
|
||||
$targetTime = strtotime('2024-10-1');
|
||||
echo '距离2024年国庆还有' . ceil(($targetTime - $currentTime) / 60 / 60 / 24) . '天<br>';
|
||||
echo microtime() . "<br>";
|
||||
$end_run_time = run_time();
|
||||
echo 'php运行时间:'.$end_run_time-$start_run_time;
|
||||
function run_time(): float
|
||||
{
|
||||
list($micro_sec, $sec) = explode(' ', microtime());
|
||||
return (float)$micro_sec + (float)$sec;
|
||||
}
|
||||
?>
|
36
10.work1.php
36
10.work1.php
|
@ -1 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>练习1</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="">
|
||||
<label for="year1">年:</label>
|
||||
<input type="text" name="year" id="year1">
|
||||
<label for="month1">月:</label>
|
||||
<input type="text" name="month" id="month1">
|
||||
<label for="day1">日:</label>
|
||||
<input type="text" name="day" id="day1">
|
||||
<label for="hour1">时:</label>
|
||||
<input type="text" name="hour" id="hour1">
|
||||
<label for="minute1">分:</label>
|
||||
<input type="text" name="minute" id="minute1">
|
||||
<label for="second1">秒:</label>
|
||||
<input type="text" name="second" id="second1">
|
||||
<input type="submit" value="提交">
|
||||
</form>
|
||||
<?php
|
||||
if (isset($_POST['year']) && isset($_POST['month']) && isset($_POST['day']) && isset($_POST['hour']) && isset($_POST['minute']) && isset($_POST['second'])) {
|
||||
$year = $_POST['year'];
|
||||
$month = $_POST['month'];
|
||||
$day = $_POST['day'];
|
||||
$hour = $_POST['hour'];
|
||||
$minute = $_POST['minute'];
|
||||
$second = $_POST['second'];
|
||||
// display the results
|
||||
// echo '你输入的时间为:' . $year . '年' . $month . '月' . $day . '日' . $hour . '时' . $minute . '分' . $second . '秒';
|
||||
$time = mktime($hour, $minute, $second, $month, $day, $year);
|
||||
echo date('Y-m-d H:i:s',$time);
|
||||
}
|
||||
?>
|
||||
</body>
|
46
10.work2.php
46
10.work2.php
|
@ -1 +1,47 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>练习2</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="">
|
||||
<label for="year1">年:</label>
|
||||
<input type="text" name="year[]" id="year1">
|
||||
<label for="month1">月:</label>
|
||||
<input type="text" name="month[]" id="month1">
|
||||
<label for="day1">日:</label>
|
||||
<input type="text" name="day[]" id="day1">
|
||||
<label for="hour1">时:</label>
|
||||
<input type="text" name="hour[]" id="hour1">
|
||||
<label for="minute1">分:</label>
|
||||
<input type="text" name="minute[]" id="minute1">
|
||||
<label for="second1">秒:</label>
|
||||
<input type="text" name="second[]" id="second1">
|
||||
<br>
|
||||
<label for="year2">年:</label>
|
||||
<input type="text" name="year[]" id="year2">
|
||||
<label for="month2">月:</label>
|
||||
<input type="text" name="month[]" id="month2">
|
||||
<label for="day2">日:</label>
|
||||
<input type="text" name="day[]" id="day2">
|
||||
<label for="hour2">时:</label>
|
||||
<input type="text" name="hour[]" id="hour2">
|
||||
<label for="minute2">分:</label>
|
||||
<input type="text" name="minute[]" id="minute2">
|
||||
<label for="second2">秒:</label>
|
||||
<input type="text" name="second[]" id="second2">
|
||||
<input type="submit" value="提交">
|
||||
</form>
|
||||
<?php
|
||||
// check if the form has been submitted
|
||||
if (isset($_POST['year']) && isset($_POST['month']) && isset($_POST['day']) && isset($_POST['hour']) && isset($_POST['minute']) && isset($_POST['second'])) {
|
||||
$dateTime1 = new DateTime();
|
||||
$dateTime1->setTimestamp(mktime($_POST['hour'][0], $_POST['minute'][0], $_POST['second'][0], $_POST['month'][0], $_POST['day'][0], $_POST['year'][0]));
|
||||
$dateTime2 = new DateTime();
|
||||
$dateTime2->setTimestamp(mktime($_POST['hour'][1], $_POST['minute'][1], $_POST['second'][1], $_POST['month'][1], $_POST['day'][1], $_POST['year'][1]));
|
||||
$interval = $dateTime1->diff($dateTime2);
|
||||
echo $interval->format("%R%Yyears %mmonths %ddays");
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
|
97
8.test1.php
97
8.test1.php
|
@ -1 +1,98 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="#">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="username1">Username</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="username1" name="username" required
|
||||
value="<?php
|
||||
echo isset($_POST['remember']) ? (in_array('username', $_POST['remember']) ? $_POST['username'] : '') : ''
|
||||
?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="remember[]" id="remember1"
|
||||
value="username" <?php echo isset($_POST['remember']) ? (in_array('username', $_POST['remember']) ? 'checked' : '') : '' ?>>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="password1">Password</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="password" name="password" id="password1" required
|
||||
value="<?php
|
||||
echo isset($_POST['remember']) ? (in_array('password', $_POST['remember']) ? $_POST['password'] : '') : ''
|
||||
?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="remember[]" id="remember2"
|
||||
value="password" <?php echo isset($_POST['remember']) ? (in_array('password', $_POST['remember']) ? 'checked' : '') : '' ?>>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center">
|
||||
<input type="radio" name="role" id="role1" value="user" checked>
|
||||
<label for="role1">User</label>
|
||||
<input type="radio" name="role" id="role2" value="admin">
|
||||
<label for="role2">Admin</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center">
|
||||
<input type="submit" value="login" name="submit" id="submit1">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form name="form1" method="post" action="">
|
||||
<table width="280" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="80" height="25" align="center"><span class="style2">意见主题:</span></td>
|
||||
<td width="194">
|
||||
<select name="select[]" size="4" multiple>
|
||||
<option value="公司发展">公司发展</option>
|
||||
<option value="管理制度">管理制度</option>
|
||||
<option value="后勤服务">后勤服务</option>
|
||||
<option value="员工薪资">员工薪资</option>
|
||||
</select>
|
||||
<input type="submit" name="submit" value="提交"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form name="form1" method="post" action="#">
|
||||
<input type="file" name="file" size="15">
|
||||
<input type="submit" name="upload" value="上传">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['submit']) && $_POST['submit'] == 'login') { // login event
|
||||
echo 'Username:' . $_POST['username'] . '<br>Password:' . $_POST['password'] . '<br>Role:' . $_POST['role'] . '<br>';
|
||||
if (count($_POST['remember']) == 0) {
|
||||
echo 'Not remember username&password';
|
||||
} else {
|
||||
foreach ($_POST['remember'] as $item) {
|
||||
echo $item . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($_POST['submit']) && $_POST['submit'] == '提交') {
|
||||
echo "你选择了:";
|
||||
for ($i = 0; $i < count($_POST['select']); $i++) {
|
||||
echo $_POST['select'][$i] . ' ';
|
||||
}
|
||||
}
|
||||
if (isset($_POST['upload']) && $_POST['upload'] == '上传') {
|
||||
if (isset($_POST['file']) && $_POST['file'] != '') {
|
||||
echo $_POST['file'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
|
@ -2,14 +2,14 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>表单</title>
|
||||
<title>用户注册</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="#">
|
||||
<form method="post" action="#" enctype="multipart/form-data">
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
信息提交表单
|
||||
<th colspan="2" style="text-align: center">
|
||||
<h1>用户注册</h1>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -25,9 +25,9 @@
|
|||
<label>性别:</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="sex" value="male" id="sex1">
|
||||
<input type="radio" name="sex" value="男" id="sex1">
|
||||
<label for="sex1">男</label>
|
||||
<input type="radio" name="sex" value="female" id="sex2">
|
||||
<input type="radio" name="sex" value="女" id="sex2">
|
||||
<label for="sex2">女</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -45,33 +45,87 @@
|
|||
</td>
|
||||
<td>
|
||||
<select name="education" size="1" id="education1">
|
||||
<option value="junior">初中</option>
|
||||
<option value="senior">高中</option>
|
||||
<option value="college">大学</option>
|
||||
<option value="master">硕士</option>
|
||||
<option value="doctor">博士</option>
|
||||
<option value="初中">初中</option>
|
||||
<option value="高中">高中</option>
|
||||
<option value="大学">大学</option>
|
||||
<option value="硕士">硕士</option>
|
||||
<option value="博士">博士</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<label>爱好:</label>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<input type="checkbox" name="hobby[]" id="hobby1" value="电脑">
|
||||
<label for="hobby1">电脑</label>
|
||||
<input type="checkbox" name="hobby[]" id="hobby2" value="音乐">
|
||||
<label for="hobby2">音乐</label>
|
||||
<input type="checkbox" name="hobby[]" id="hobby3" value="旅游">
|
||||
<label for="hobby3">旅游</label>
|
||||
<input type="checkbox" name="hobby[]" id="hobby4" value="其他">
|
||||
<label for="hobby4">其他</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<label for="photo1">头像:</label>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<input type="file" size="5" accept=".jpg, .jpeg, .png, .gif" id="photo1" name="photo" required>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="note1">个人简介:</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="note" id="note1" wrap="hard"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center">
|
||||
<input type="submit" name="submit" value="提交">
|
||||
<input type="reset" name="reset" value="重置">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (isset($_POST['submit']) && $_POST['submit'] != '') {
|
||||
echo '###提交的信息如下###<br>';
|
||||
echo '姓名:' . $_POST['name'] . '<br>';
|
||||
echo '性别:' . $_POST['sex'] . '<br>';
|
||||
echo '密码:' . $_POST['password'] . '<br>';
|
||||
if (isset($_POST['education']) && $_POST['education'] != '') {
|
||||
echo '学历:' . $_POST['education'] . '<br>';
|
||||
}
|
||||
if (isset($_POST['hobby']) && count($_POST['hobby']) != 0) {
|
||||
echo '爱好:';
|
||||
foreach ($_POST['hobby'] as $item) {
|
||||
echo $item . ' ';
|
||||
}
|
||||
echo '<br>';
|
||||
}
|
||||
|
||||
if ($_FILES["photo"]["error"] > 0) {
|
||||
echo "Error: " . $_FILES["photo"]["error"];
|
||||
} else {
|
||||
$file_org = $_FILES["photo"]["tmp_name"];
|
||||
$file_target = 'images/' . basename($_FILES["photo"]["name"]);
|
||||
if (move_uploaded_file($file_org, $file_target)) {
|
||||
echo '头像:' . '<img style="max-width: 100px; max-height: 100px;" alt="person photo" src="' . $file_target . '"><br>';
|
||||
} else {
|
||||
echo "头像上传失败。";
|
||||
}
|
||||
}
|
||||
if (isset($_POST['note']) && $_POST['note'] != '') {
|
||||
echo '个人介绍:' . nl2br($_POST['note']) . '<br>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
21
8.work2.php
21
8.work2.php
|
@ -1 +1,20 @@
|
|||
<?php
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>搜索</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="8.work2.search.php" method="get">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" size="30" name="keyword" id="keyword1" placeholder="请在此输入关键词" required>
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="submit" value="搜索">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
|
@ -1 +1,4 @@
|
|||
<?php
|
||||
if(isset($_GET['submit'])&& $_GET['submit']!=''){
|
||||
echo '本次搜索的关键词为: '.$_GET['keyword'];
|
||||
}
|
52
9.test1.php
52
9.test1.php
|
@ -1 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>test1</title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="form1" method="post" action="" id="year_form">
|
||||
<span>检测闰年:</span>
|
||||
<select name="year">
|
||||
<option value="2000">2000年</option>
|
||||
<option value="2001">2001年</option>
|
||||
<option value="2002">2002年</option>
|
||||
<option value="2003">2003年</option>
|
||||
<option value="2004">2004年</option>
|
||||
<option value="2005">2005年</option>
|
||||
<option value="2006">2006年</option>
|
||||
<option value="2007">2007年</option>
|
||||
<option value="2008">2008年</option>
|
||||
</select>
|
||||
<input type="submit" name="Submit" value="提交" onclick="check()">
|
||||
</form>
|
||||
<form name="form2" method="post" action="" id="login">
|
||||
<label for="username1">用户名</label><input type="text" name="username" id="username1"><br>
|
||||
<label for="password1">密码</label><input type="password" name="password" id="password1"><br>
|
||||
<input type="submit" name="submit" value="登录" onclick="return mycheck()">
|
||||
</form>
|
||||
<?php
|
||||
|
||||
?>
|
||||
<script>
|
||||
function check(){
|
||||
var year = document.getElementById("year_form").year.value;
|
||||
if((year%4===0)&&year%100!==0){
|
||||
alert(year+"是闰年");
|
||||
}else {
|
||||
alert(year+"是平年");
|
||||
}
|
||||
}
|
||||
function mycheck(){
|
||||
var form2 = document.getElementById('login');
|
||||
if(form2.username.value===""){
|
||||
alert("用户名不能为空");
|
||||
form2.username.focus();
|
||||
return false;
|
||||
}else if (form2.password.value===""){
|
||||
alert("密码不能为空");
|
||||
form2.password.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
68
9.work1.php
68
9.work1.php
|
@ -1 +1,67 @@
|
|||
<?php
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>test1</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="" method="post" id="new_form">
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2" style="text-align: center">
|
||||
博客 发表文章
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="title1">文章主题:</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="title1" id="title1">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="content1">文章内容:</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="content" id="content1" style="height: 200px;width: 200px"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="author1">作者:</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="author" id="author1">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: center">
|
||||
<input type="submit" name="submit" value="发表" onclick="return check()">
|
||||
<input type="reset" name="reset" value="重置">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<script>
|
||||
function check(){
|
||||
var form = document.getElementById('new_form');
|
||||
if(form.title1.value===""){
|
||||
alert("文章主题不能为空");
|
||||
form.title1.focus();
|
||||
return false;
|
||||
}else if (form.content.value===""){
|
||||
alert("文章内容不能为空");
|
||||
form.content.focus();
|
||||
return false;
|
||||
}else if (form.author.value===""){
|
||||
alert("文章作者不能为空");
|
||||
form.author.focus();
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
12
9.work2.php
12
9.work2.php
|
@ -1 +1,11 @@
|
|||
<?php
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>实时时间</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="time"></h1>
|
||||
<script src="realtime.js"></script>
|
||||
</body>
|
18
9.work3.php
18
9.work3.php
|
@ -1 +1,17 @@
|
|||
<?php
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>字数统计</title>
|
||||
</head>
|
||||
<body>
|
||||
<label for="freeText1">请在此输入文本内容</label>
|
||||
<br>
|
||||
<textarea name="freeText" id="freeText1" style="width: 500px;height: 500px;" oninput="countText()"></textarea>
|
||||
<h1 id="count_freeText">0</h1>
|
||||
<script>
|
||||
function countText() {
|
||||
document.getElementById("count_freeText").innerText = document.getElementById("freeText1").value.length;
|
||||
}
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,7 @@
|
|||
function showCurrentTime() {
|
||||
const CurrentTime = new Date();
|
||||
document.getElementById('time').innerHTML = CurrentTime.toLocaleString();
|
||||
}
|
||||
|
||||
window.onload = showCurrentTime(); // 页面加载完毕后执行
|
||||
setInterval(showCurrentTime, 1000);
|
Loading…
Reference in New Issue