Blogger Information
Blog 37
fans 0
comment 0
visits 20808
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP编程第五课:php基础5-PHP培训九期线上班
渡劫小能手
Original
597 people have browsed it

一、练习get传值


实例

<!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="">
    <label for="password">密码:</label>
    <input type="password" id="password" name="password" value="">
    <br/>

    <button>登录</button>
</form>
</body>
</html>
<?php
print_r($_GET);
echo '<br/>';
print_r($_GET['email']);
?>

运行实例 »

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

2019-11-18_130742.png

二、练习流程控制 (手写)

1、if else

实例

<?php
$var = 60;
if ($var == 100) {
    echo '出去旅游';
}elseif ($var >= 80) {
    echo  '在家过年';
}elseif ($var >= 60) {
    echo '帮忙干活';
}else {
    echo '挨打';
}

运行实例 »

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

2019-11-18_112433.png

2、switch


实例

<?php
$var = 50;
switch ($var) {
    case 100:
        echo '出去旅游';
        break;
    case $var>=80:
        echo '在家过年';
        break;
    case $var>=60:
        echo '帮忙干活';
        break;
    default:
        echo '挨打';
        break;
}

运行实例 »

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

2019-11-18_114747.png

三、练习计数循环 (手写)

1、while


实例

<?php
$num = 1;
while ($num < 10) {
    echo $num++;
    echo '<hr/>';
}

运行实例 »

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

2019-11-18_120403.png

2、for


实例

<?php
for ($int = 1;$int < 9; $int++) {
    echo $int;
    echo '<hr/>';
}

运行实例 »

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

2019-11-18_122955.png

四、总结

1、if和switch功能一样,if在不知道多少个的时候用,switch在知道有多少个值时候用

2、if和switch都是流程控制,foreach是数组循环

3、if、switch、while都是先看条件是否成立,成立则执行;而do while是先执行,不管条件成不成立

4、for、while是计数循环,foreach是数组循环

5、continue可以用在while、for、foreach,break用在while、for、switch、foreach

6、传递的值存储在$_GET数组中,GET里面的key就是form表单里面的input name,GET里面的value就是form表单里面的input value

2019-11-18_131725.png

2019-11-18_131740.png

2019-11-18_131749.png

Correcting teacher:天蓬老师天蓬老师

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!