• Save
第六章解答
Upcoming SlideShare
Loading in...5
×
 

第六章解答

on

  • 578 views

 

Statistics

Views

Total Views
578
Views on SlideShare
578
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

第六章解答 第六章解答 Document Transcript

  • 第 6 章解答 PHP 6 與 MySQL 基礎學習教室1.請說明 for 迴圈內三個參數意義。解答:三個參數分別代表變數初始值、變數的判斷式與每執行一次迴圈後變數的變化2.當條件不成立時,while 及 do while 迴圈會執行嗎?解答:當條件不成立時,while 不會執行,而 do while 迴圈會執行一次。3.當條件成立,希望能中斷網頁的執行,請問該用哪一個中斷指令?解答:exit;可中斷網頁的執行。4.當條件成立,希望能跳出最近的迴圈,請問該用哪一個中斷指令?解答:break;可跳出最近的迴圈。5.當條件成立,希望能中止現在的迴圈而繼續執行下一個迴圈,請問該用哪一個中斷指令?解答:continue;可中止現在的迴圈而繼續執行下一個迴圈。6.PHP 陣列可否使用文字當作索引值?請舉例。解答:<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>文字作為索引值的陣列</title></head><body><?$a["db"] = "mysql";$a["web"] = "apache";$a["cgi"] = "php";echo $a["web"]."<hr>";?></body></html> 第1頁
  • 第 6 章解答 PHP 6 與 MySQL 基礎學習教室7.PHP 陣列數字索引值是由哪一個數值開始?解答:數字索引值是由 0 開始。8.foreach 語法如何顯示出索引值?請舉例。解答:<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>foreach index</title></head><body><?$grade[0] = 80;$grade[1] = 60;$grade[2] = 90;$grade[3] = 50;$grade[4] = 70;foreach ($grade as $key1 =>$value1) echo "座號".($key1+1)."同學的成績為:".$value1."<br>";?></body></html>9.核選框若要以分組方式設計,該如何設計?解答:核選框建立時需以陣列的形式建立。例如:<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>分類的核選框</title></head><body><form name="form5" method="get" action="ex10.php" charset="utf-8">旅遊選擇:<br><input type="checkbox" value="台北三日遊" name="travel[]">台北三日遊<input type="checkbox" value="雲嘉四日遊" name="travel[]">雲嘉四日遊<br><input type="checkbox" value="高鐵" name="transport[]">高鐵<input type="checkbox" value="飛機" name="transport[]">飛機<input type="checkbox" value="台鐵" name="transport[]">台鐵<input type="submit"><input type="reset"></form></body></html> 第2頁
  • 第 6 章解答 PHP 6 與 MySQL 基礎學習教室10.若要接收分組的核選框資訊,該如何判斷分析目前接收的資料?解答:分組核選框可用 foreach 方式取值。例如:<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>接收分類的核選框</title></head><body><?echo "旅遊選擇:"."<br>";foreach ($_GET[travel] as $w)echo $w."<br>";echo "請挑選交通工具:"."<br>";foreach ($_GET[transport] as $l)echo $l."<br>";?></body></html> 第3頁