
批改狀態(tài):合格
老師批語:完成的不錯(cuò),繼續(xù)努力
`
<!--//2、POST 請求-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>POST 請求</title>
</head>
<body>
<form action="" method="post">
<label for="email">郵箱:</label>
<input type="email" id="email" name="email" value="<?php echo isset($_POST['email'] ) ? $_POST['email'] : ''; ?>">
<label for="password">密碼:</label>
<input type="password" id="password" name="password" value="<?php echo $_POST['password'] ? $_POST['password'] : '';?>">
<button>登錄</button>
</form>
</body>
</html>
<?php
echo $_POST[‘email’];
echo ‘<br>‘;
echo $_POST[‘password’];
echo ‘<br>‘;
// 獲取變量之前要進(jìn)行判斷,用isset()
//if (isset($_POST[‘password’])) {
// echo $_POST[‘password’];
//} else { // 給個(gè)默認(rèn)值
// echo ‘空’;
//}
if (empty($_POST[‘password’])) {
echo ‘null’;
} else { // 給個(gè)默認(rèn)值
echo $_POST['password'];
}
echo ‘<hr>‘;
echo ‘<pre>‘;
print_r($_POST);`
`<?php
//strtolower() 將字符串轉(zhuǎn)化為小寫
$str = ‘ASDFG’;
$str =strtolower($str);
echo $str;
echo ‘<hr>‘;
//strtoupper 將字符串轉(zhuǎn)化為大寫
$str = strtoupper($str);
echo $str;
echo ‘<hr>‘;
//strlen() 獲取字符串長度
echo strlen($str);
echo ‘<hr>‘;
//str_replace() 字符串替換
$a= str_replace(‘AS’,’GXG’,$str);
echo $a;
echo ‘<hr>‘;
//9、md5()
$str = ‘123456’;
echo md5($str);
echo ‘<hr>‘;
//count() 數(shù)組中元素的數(shù)量
$arr = array(
‘歐陽克’,
‘黃蓉’,
‘郭靖’
);
echo count($arr);
echo ‘<hr>‘;
//2、array_merge()
$arr1 = array(
‘歐陽克’,
‘黃蓉’
);
$arr2 = array(
‘郭靖’,
‘楊康’
);
$arr3 = array_merge($arr1,$arr2);
print_r($arr3);
echo ‘<hr>‘;
`
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號