这次实践的都是PHP7的语法。

感觉是以前的5差别不是那么大,只是希望越来越快吧。

<?php
    $looking = isset($_GET['title']) || isset($_GET['author'])
?>
<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta charset='UTF-8'>
        <title>BookStore</title>
    </head>
    <body>
        <?php
        echo "Befor the conditional.<br/>";
        if (2 > 2) {
            echo "Inside the conditional.<br/>";
        } elseif ( 2 == 2) {
            echo "Print when 2 == 2.<br/>";
        } elseif ( 2 < 2) {
            echo "Not evaluted.<br/>";
        } else {
            echo "Inside the else.<br/>";
        }
        echo "After the conditional.<br/>";

        $title = 'Harry Potter';
        switch ($title) {
            case 'Harry Potter':
                echo 'Nice story. a bit too long.';
                break;
            case 'Load of the Rings':
                echo 'A classic!';
                break;
            default:
                echo 'Dunno that one.';
                break;
        }
        echo "<br/>";

        $i = 1;
        while ($i < 4) {
            echo $i . "<br/>";
            $i++;
        }
        echo "<br/>";
        $i = 1;
        do {
            echo $i . "<br/>";
            $i++;
        } while ($i < 0);

        for ($i = 1; $i < 10; $i++) {
            echo $i . "<br/>";
        }

        $names = ['Harry', 'Ron', 'Hermione'];
        for ($i = 0; $i < count($names); $i++) {
            echo $names[$i] . "<br/>";
        }

        foreach ($names as $name) {
            echo $name . "<br/>";
        }

        foreach ($names as $key => $name) {
            echo $key . ' -> ' . $name .  "<br/>";
        }
        ?>

    </body>
</html>

输出:

Befor the conditional.
Print when 2 == 2.
After the conditional.
Nice story. a bit too long.
1
2
3

1
1
2
3
4
5
6
7
8
9
Harry
Ron
Hermione
Harry
Ron
Hermione
0 -> Harry
1 -> Ron
2 -> Hermione

最新文章

  1. JqueryUI Dialog 加载动态页 部分页
  2. 大话css之display的Block未解之谜(一)
  3. 自定义HttpModule的一些经验--配置篇
  4. C#枚举描述获取
  5. meta中的viewport指令
  6. rsync 不能同不子级目录的问题
  7. EF小节
  8. SecureCRT恢复默认字体
  9. POJ 1159 Palindrome 最长公共子序列的问题
  10. CF-Mr. Kitayuta&#39;s Colorful Graph
  11. C5-信号量与PV操作(iOS篇-细说信号量)
  12. 第六章 Hibernate关联映射
  13. 苹果系统css样式变化
  14. BZOJ 4569: [Scoi2016]萌萌哒 [并查集 倍增]
  15. WEB中间件--tomcat爆破,burp和python脚本
  16. 在IIS中如何配置SSL(https)
  17. vue当前路由跳转初步研究
  18. 重定向、feed输出:控制台输出的内容存放到文件
  19. Java中代码点与代码单元(转)
  20. 【原创】user.id字段

热门文章

  1. 怎么去掉织梦(dedecms)网站首页默认携带的index.html尾巴
  2. 各手机PC品牌投屏功能连接方法
  3. linux查看端口常用命令
  4. Centos 7搭建Gitlab服务器超详细
  5. Python实现字典树
  6. C++中几种字符串表示方法
  7. 【rt-thread】1、快速建立rt-thread nano最小裁剪工程
  8. IDEA中使用git
  9. 常见的python练习题
  10. 2019-07-24 require 和 include的区别