Blogger Information
Blog 25
fans 0
comment 0
visits 15877
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0722-POST和GET
杨发国的博客
Original
736 people have browsed it

作业1

实例

<?php

$home='我爱我家';
$member=[0=>'爸爸',1=>'妈妈',2=>'我'];
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?php echo $home; ?></title>
</head>
<body>
<h2><?php echo $home; ?></h2>

<ul>

<?php foreach ($member as $member): ?>
  <li><a href=""><?php echo $member; ?></a></li>
<?php endforeach;?>
</ul>




<!--使用foreach替代语法,干掉大括号, 将大括号用冒号代替-->


</body>
</html>

运行实例 »

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

作业2get

实例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>get作业</title>
</head>
<body>
<form action="" method="get">
    <p>
        <label for="user">用户:</label>
        <input type="text" id="user" name="user" value="">
    </p>
    <p>
    <label for="password">密码:</label>
    <input type="password" id="password" name="password" value="">
    </p>
    <p>
        <button>登录</button>
    </p>
</form>
</body>
</html>

<?php

echo isset($_GET['user']) ? $_GET['user'] : '';
echo isset($_GET['password']) ? $_GET['password'] : '';
//echo '<pre>';
//print_r($_GET);
?>

运行实例 »

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

作业2POST

实例

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>POST作业</title>
</head>
<body>
<form action="" method="POST">
    <p>
        <label for="user">用户:</label>
        <input type="text" id="user" name="user" value="">
    </p>
    <p>
    <label for="password">密码:</label>
    <input type="password" id="password" name="password" value="">
    </p>
    <p>
        <button>登录</button>
    </p>
</form>
</body>
</html>

<?php

echo isset($_POST['user']) ? $_POST['user'] : '';
echo isset($_POST['password']) ? $_POST['password'] : '';

?>

运行实例 »

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

 

Correction status:qualified

Teacher's comments:在与html混编的时候,替代语法非常的方便
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