<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>php学习笔记</title>
        <style>
            <!--修改css-->
            body {background-color:black; color:white;}
            h1{font: 72pt arial bold;}
        </style>
    </head>
    <body>
        <?php
        //注释
        #注释
        /*
         * 注释
         */
        $a = 5;
        $b = 010; //八进制
        $c = 0xf;
        echo '$b=' . "$b<br>";
        print '$c=' . "$c<br>";
        echo '$a<br>'; //单引号对引号里不识别
        print '$a<br>';

        //转义字符\n换行并归零 \br换行 \t \' \" \$ \r回车(这里的换行符是显示在源代码里面的换行符,在网页里并不会显示)
        //null 1)被赋值null 2)尚未被赋值  3)被unset

        $var = 1.1;
        echo "$var is a " . gettype($var) . "<br>"; //.用于连接字符串,输出1.1 is a double
        var_dump($var); //输出变量类型,这里是:float
        //转换变量类型->自动由小到大
        //强制转换 cast或settype();
        echo "<br><br>";
        //$_SERVER组的内变量
        echo "目前执行的文件名称" . $_SERVER['PHP_SELF'] . "<br>";
        echo "服务器名" . $_SERVER['SERVER_NAME'] . "<br>";
        echo "服务器软件" . $_SERVER['SERVER_SOFTWARE'] . "<br>";
        echo "文档的根目录" . $_SERVER['DOCUMENT_ROOT'] . "<br>";
        echo "用户相关信息" . $_SERVER['HTTP_USER_AGENT'] . "<br>";
        echo "远程用户的地址" . $_SERVER['REMOTE_ADDR'] . "<br>";
        echo "远程用户的连接端口" . $_SERVER['REMOTE_PORT'] . "<br>";

        include "GetIP.php";
        GetIP();

        //常量
        echo "你的系统是:" . PHP_OS . "<br>";
        echo "目前使用的PHP版本是:" . PHP_VERSION . "<P>";
        //自定义常量
        define("PI", 3.14159);
        echo PI . "<br>";

        //运算符同c,注意.是连接字符串运算符
        //位运算符同;逻辑运算符:^按位异或 xor异或 and/&&与 or/||或 !非
        /* 其他运算符
         * &取地址
         * @不显示错误信息
         * ?=三目
         * ,逗号运算符
         * ->应用对象的方法和属性
         * =>数组赋值
         */

        //流程控制,if() eles;
        //while(){}
        //
        // switch{ case 1: ; break; default;} 同样
        //注意for(,,){}用,分隔
        //输出99乘法表
        print("<table border=1>"); //表格开始
        for ($row = 1; $row <= 9; $row++) {
            print("<tr>\n");
            for ($column = 1; $column <= $row; $column++) {
                print("<td>");
                print($row * $column);
                print("</td>");
            }
            print("</tr>");
        }
        print("</table>");

        //global $int;全局变量
        //static $num=0; $num++;静态变量,第一次定义有效
        //
        //函数变量
        function testvar() {
            echo "testvar()函数<br>";
        }

        function setname($string) {
            echo "my name is $string";
        }

        $rtext = 'testvar';
        $rtext();
        $rtext = 'setname';
        $rtext("Jun");

        ?>
    </body>
</html>