day1

<?php
//if(dns_check_record("php.net", "MX"))
//    {
//        print("php.net is a mail exchanger");
//    }

//1.打印出用戶的瀏覽器類型和版本號
//    print("User Agent: {$_SERVER['HTTP_USER_AGENT']}<br>/n");
//    //try to parse User Agent
//    if(ereg("^(.+)/([0-9])/.([0-9]+)",
//        $_SERVER['HTTP_USER_AGENT'], $matches))
//    {
//        print("Full match: $matches[0]<br>/n");
//        print("Browser: $matches[1]<br>/n");
//        print("Major Version: $matches[2]<br>/n");
//        print("Minor Version: $matches[3]<br>/n");
//    }
//    else
//    {
//        print("User Agent not recognized");
//    }


//2:打亂數組順序
// swap newlines for break tags
//    $text = "line1/nline2/nline3/n";
//    print(ereg_replace("/n", " dd ", $text));
//
//    print("<hr>/n");
//
//    //mix up these words
//    $text = "one two three four";
//    print(ereg_replace("([a-z]+) ([a-z]+) ([a-z]+) ([a-z]+)",
//        "//4 //2 //1 //3", $text));


    /*
    ** if zip submitted evaluate it
    */

    //3:判斷是否是一個zip號
//    if(isset($_REQUEST['zip']))
//    {
//        if(ereg("^([0-9]{5})(-[0-9]{4})?$", $_REQUEST['zip']))
//        {
//            print("{$_REQUEST['zip']} is a valid ZIP code.<br>/n");
//        }
//        else
//        {
//            print("{$_REQUEST['zip']} is <b>not</b> " .
//               "a valid ZIP code.<br>/n");
//        }
//    }
//
//    //start form
//    print("<form action=/"{$_SERVER['PHP_SELF']}/">/n");
//    print("<input type=/"text/" name=/"zip/">/n");
//    print("<input type=/"submit/">/n");
//    print("</form>/n");

//    //set URL to fetch

//3:找到一個網頁上的所有的鏈接
// $URL = "http://www.php.net/";
//
//    //open file
//    $page = fopen($URL, "r");
//
//    print("Links at $URL<br>/n");
//    print("<ul>/n");
//
//    while(!feof($page))
//    {
//        //get a line
//        $line = fgets($page, 1024);
//
//        //loop while there are still URLs present
//        while(eregi("href=/"[^/"]*/"", $line, $match))
//        {
//            //print out URL
//            print("<li>{$match[0]}</li>/n");
//
//            //remove URL from line
////            $replace = ereg_replace("/?", "/?", $match[0]);
//            $line = "";
//        }
//    }
//
//    print("</ul>/n");
//
//    fclose($page);


// 4:去除頁面提交過來的多餘的空格
/*
    ** if text submitted show it
    */
//    if(isset($_REQUEST['text']))
//    {
//        print("<b>Unfiltered</b><br>/n" .
//            "<pre>{$_REQUEST['text']}</pre>" .
//            "<br>/n");
//
//        $_REQUEST['text'] = ereg_replace("[[:space:]]+",
//            " ", $_REQUEST['text']);
//
//        print("<b>Filtered</b><br>/n" .
//            "<pre>{$_REQUEST['text']}</pre>" .
//            "<br>/n");
//    }
//    else
//    {
//        $_REQUEST['text'] = "";
//    }
//
//    //start form
//    print("<form action=/"{$_SERVER['PHP_SELF']}/">/n" .
//        "<textarea name=/"text/" cols=/"40/" rows=/"10/">" .
//        "{$_REQUEST['text']}</textarea><br>/n" .
//        "<input type=/"submit/">/n" .
//        "</form>/n");


?>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章