Blogger Information
Blog 20
fans 0
comment 0
visits 25257
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php工作原理&get与post请求
左手Leon的博客
Original
746 people have browsed it

php手绘.jpg

实例-get.php

<?php
// 获取通过url发送的变量参数
// 键名=>变量名, 值=>变量值

function _get($str){
    $val = !empty($_GET[$str]) ? $_GET[$str] : null;
    return $val;
}

?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>get</title>
</head>
<body>
<form action="" method="get">
    <label for="email">邮箱:</label>
    <input type="email" id="email" name="email" value="<?=_get('email')?:''?>">

    <label for="password">密码:</label>
    <input type="password" id="password" name="password" value="<?=_get('password')?:''?>">

    <button>登录</button>
</form>
</body>
</html>
<?php
// 获取通过请求头发送的变量参数
// 键名=>变量名, 值=>变量值
echo '<pre>';
print_r($_GET);
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<?php
// 获取通过请求头发送的变量参数
// 键名=>变量名, 值=>变量值
function _post($str){
    $val = !empty($_POST[$str]) ? $_POST[$str] : null;
    return $val;
}

?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>get</title>
</head>
<body>
<form action="" method="post">
    <label for="email">邮箱:</label>
    <input type="email" id="email" name="email" value="<?=_post('email')?:''?>">

    <label for="password">密码:</label>
    <input type="password" id="password" name="password" value="<?=_post('password')?:''?>">

    <button>登录</button>
</form>
</body>
</html>
<?php

echo '<pre>';
print_r($_POST);
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例



Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post