• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            小默

            php study

            1.
            <?PHP
            //1
            //phpinfo();

            //2
            //print "hello world";

            //3
            //$num1 = 8;
            //$num2 = 23;


            print $_GET['user']."<br/>";
            print "Welcome <b>".$_POST['user']."</b><br/>\n\n";

            //print $num2;
            ?>

            2.
            <!DOCTYPE html PUBLIC
               
            "-//W3C//DTD XHTML 1.0 Strict//EN"
             
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <html>
            <head>
            <title>A PHP Script Including HTML</title>
            </head>
            <body>
            <div><b>
            <?php
            print "hello world";
            ?>
            </b></div>
            </body>
            </html>

            3.
            <?PHP
            //const
            define ("USER","colorfulgreen"); //定義一個常量
            print "Welcome ".USER; //'.'表示連接
            print "<br />";        //換行
            print "the second line.";
            ?>

            4.
            <?php
            //程序流程
            //switch

            $satisfied = "c.g";
            if($satisfied == "cg"){
                
            print "go into the if.";
            }
            else{
                
            print "go into the else.";
            }

            //switch case
            //? :


            print "<br />";

            $count = 1;
            while($count < 12){
                
            print $count."<br />";
                
            $count++;
            }

            //dowhile
            //for
            //break
            //continue

            ?>

            5.
            <?php
            //func
            //ex.1

            $num = -321;
            $newnum = abs($num);
            print $newnum;

            //print "<br />";

            //ex.2.自定義函數(shù)

            function bighello()
            {
                
            print "<h1>HELLO</h1>";
            }
            bighello();

            //ex.3.帶參數(shù)
            function printBR($txt)
            {
                
            print ("$txt<br />\n");
            }
            printBR(
            "this is the first line.");
            printBR(
            "this is the second line.");

            //ex.4.A Function That Returns a Value
            function addNums($firstnum,$secondnum)
            {
                
            $result = $firstnum + $secondnum;
                
            return $result;
            }
            print "<br />Function That Returns a Value"."<br />";
            print addNums(6,5);

            //ex.5.Calling a Function Dynamically
            //類似與函數(shù)指針

            print "<br /><br />Calling a Function Dynamically<br />";
            function sayHello()
            {
                
            print "hello<br />";
            }
            $function_holder = "sayHello";
            $function_holder();

            //ex.6.Variable Scope
            print "<br /><br />Variable Scope<br />";
            function test()
            {
                
            $testvariable = "this is a test variable";
            }
            print "test variable: $testvariable";

            //ex.7.global & static
            print "<br /><br />global & static<br />";
            $num_of_calls = 0;
            function numberedHeading($txt)
            {
                
            global $num_of_calls;
                
            $num_of_calls++;
                
            print "$num_of_calls.$txt<br />";
            }
            numberedHeading(
            "the first callglobal");
            numberedHeading(
            "the second callglobal");
            //用局部靜態(tài)變量,和上面輸出一樣
            function numberedHeading2($txt)
            {
                
            static $num_of_calls2 = 0;
                
            $num_of_calls++;
                
            print "$num_of_calls.$txt<br />";
            }
            numberedHeading2(
            "the first callglobal");
            numberedHeading2(
            "the second callglobal");

            //ex.7.A Function Requiring Two Arguments
            function headingWrap($txt,$size)
            {
                
            print "<h$size>$txt</h$size>";
            }
            headingWrap(
            "Book title",1);
            headingWrap(
            "Chapter title",2);

            //ex.8.A Function with an Optional Argument
            function headingWrap2($txt,$size = 3)
            {
                
            print "<h$size>$txt</h$size>";
            }
            headingWrap2(
            "Book title",1);
            headingWrap2(
            "Chapter title");

            //ex.9.Passing an Argument to a Function by Value
            function addFive($num)
            {
                
            $num +=5;
            }
            $orignum = 10;
            addFive(
            $orignum);
            print "$orignum<br />";

            //ex.10.Pass an Argument to a Function by Reference
            //???

            function addFive2(&$num)
            {
                
            $num +=5;
            }
            $orignum2 = 10;
            addFive(
            $orignum2);
            print "$orignum2<br />";

            //ex.11.A Simple Anonymous Function,函數(shù)指針
            $my_anon = create_function('$a,$b','return $a + $b;');
            print $my_anon(3,9);

            ?>

            6.
            <?php
            //array

            //ex.1.

            $users = array("Bert","Sharon","Bettery","Harry");
            print $users[2]."<br />";

            //ex.2.Defining Associative Arrays with the array() Construct
            $character = array(
              
            "name" => "bob",
              
            "occupation" => "superhero",
              
            "age" => 30,
              
            "special power" => "x-ray vision"
              );
            print $character["age"];

            //ex.3.Defining a Multidimensional Array

            //未完

            ?>

             

            7.

            <?php
            /*
            //http://localhost/10.php?user=cg&address=192.168.x.x
            print "Welcome <b>".$_GET['user']."</b><br/>\n\n";
            print "Your address is: <br/><b>".$_GET['address']."</b>";
            */

            print $_GET['user']."<br/>";

            print "Welcome <b>".$_POST['user']."</b><br/>\n\n";
            print "Your address is: <br/><b>".$_POST['address']."</b>";

            if ( is_array$_POST['products'] ) )
            {
                
            print "<p>Your product choices are:</p>\n";
                
            print "<ul>\n";
                
            foreach ( $_POST['products'as $value )
                {
                   
            print "<li>$value</li>\n";
                }
                
            print "</ul>\n";
            }
            ?>

            posted on 2010-05-15 07:59 小默 閱讀(407) 評論(0)  編輯 收藏 引用 所屬分類: Language

            導(dǎo)航

            統(tǒng)計

            留言簿(13)

            隨筆分類(287)

            隨筆檔案(289)

            漏洞

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久亚洲精品中文字幕三区| 久久精品国产第一区二区| 欧美久久亚洲精品| 久久天天婷婷五月俺也去| 一本一道久久综合狠狠老| 国内精品人妻无码久久久影院 | 欧美熟妇另类久久久久久不卡| 麻豆成人久久精品二区三区免费 | 久久精品国产精品亚洲人人| 亚洲伊人久久成综合人影院 | 一级女性全黄久久生活片免费 | 久久国产成人午夜aⅴ影院 | 国产免费久久精品丫丫| 久久狠狠爱亚洲综合影院| 亚洲国产二区三区久久| 久久久久久曰本AV免费免费| 一本一道久久精品综合| 亚洲AV无码久久精品狠狠爱浪潮| 99久久人人爽亚洲精品美女| 色妞色综合久久夜夜| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久精品无码一区二区WWW| 国产精品热久久无码av| 久久精品国产亚洲av水果派| 中文字幕精品久久| 久久丝袜精品中文字幕| 国产精品永久久久久久久久久| 国内精品久久人妻互换| 99久久精品午夜一区二区| 久久综合精品国产二区无码| 久久精品国产亚洲AV影院| 久久天天婷婷五月俺也去| 久久中文字幕精品| 老男人久久青草av高清| 久久91精品国产91| 99久久99久久精品国产片果冻| 亚洲欧洲久久av| 伊人久久精品无码二区麻豆| 亚洲日韩中文无码久久| 久久国产精品99精品国产| 久久免费精品一区二区|