Blogger Information
Blog 4
fans 0
comment 0
visits 1946
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
7月23号作业,使用foreach与它的替代语法,在html中输出数组内容;演示get和post的数据处理过程t
joe的博客
Original
418 people have browsed it

实例

<?php
//定义一个数组用于foreach遍历
$arr = ["中国","美国","英国","法国","俄罗斯"];

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>使用foreach与它的替代语法,在html中输出数组内容;演示get和post的数据处理过程t</title>
</head>
<body>
    <h5>foreach遍历数组演示</h5>
        <ul>
            <?php foreach ($arr as $value): ?>
            <li><?php echo $value; ?></li>
            <?php endforeach; ?>
        </ul>
    <hr>
    <h5>GET请求演示</h5>
    <form action="" method="GET" >
        <p>
            邮箱:
            <input type="text" name="email" value="">
        </p>
        <p>
            密码:
            <input type="password" name="password" value="">
        </p>
        <p>
            <button>提交</button>
        </p>
    </form>
<?php
$val1 = $_GET["email"];
$val2 = $_GET["password"];
echo $val1 ?? '邮箱为空';
echo "</br>";
echo $val2 ?? '密码为空';

?>
    <hr>
    <h5>POST请求演示</h5>
    <form action="" method="post" >
        <p>
            邮箱:
            <input type="text" name="email1" value="">
        </p>
        <p>
            密码:
            <input type="password" name="password1" value="">
        </p>
        <p>
            <button>提交</button>
        </p>
    </form>
<?php
$val3 = $_POST["email1"];
$val4 = $_POST["password1"];
echo $val3 ?? '邮箱为空';
echo "</br>";
echo $val4 ?? '密码为空';

?>
</body>
</html>

运行实例 »

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


Correction status:qualified

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!