引入外部程式.pptVIP

  • 0
  • 0
  • 约4.54千字
  • 约 29页
  • 2020-05-26 发布于湖北
  • 举报
Today’s Work 讓使用者輸入 生日 身高 體重 輸出 星座名稱 + 圖案 魔羯座 /images/01.gif 水瓶座 /images/02.gif … 出生年是否為潤年 當天星期幾 BMI + 體態評語 * Introduction to PHP * 計算公式 潤年 四年一潤,百年不潤,四百年潤。 星期幾?? 自己想 BMI 體重/身高2 (KG/M) 評語自己思考 * Introduction to PHP * And So On… BASIC of PHP BASIC of PHP BASIC of PHP BASIC of PHP BASIC of PHP BASIC of PHP Web Service Programming 張賢宗 註解 Comments ?php ????echo?This?is?a?test;?//?This?is?a?one-line?c++?style?comment ????/*?This?is?a?multi?line?comment ???????yet?another?line?of?comment?*/ ????echo?This?is?yet?another?test; ????echo?One?Final?Test;?#?This?is?a?one-line?shell-style?comment ? BASIC of PHP * 引入外部程式 include() and require() include(“aa.php”); require(“bb.php”); require will terminate when file open error include will continue when file open error BASIC of PHP * 引入一次 include_once require_once BASIC of PHP * 命名規則 變數開頭 $ 第一個字元: _, a-z, A-Z, 0x7f-0xff 第二個字元 _, a-z, A-Z, 0-9, 0x7f-0xff 大小寫是有差別的 Example: $sample, $c30 BASIC of PHP * 自訂函數 function 函數名稱( 參數1, 參數2…) function add( $a1, $a2 ) { return $a1+$a2; } echo add(10,20); BASIC of PHP * 變數 Scope ?php $a = a; // 全域 $b = b; // 全域 function test() { global $b; $c = c; // 區域 echo 從函式內部\n; echo $a = . $a . \n; // 無法存取 echo $b = . $b . \n; echo $c = . $c . \n; } header(Content-Type: text/plain; charset=big5); test(); echo 從函式外部\n; echo $a = . $a . \n; echo $b = . $b . \n; echo $c = . $c . \n; // 無法存取 ? BASIC of PHP * 型態 Booleans Integers Floating point numbers Strings Arrays Objects Resources NULL BASIC of PHP * Boolean $bool_var = TRUE $bool_var = FALSE BASIC of PHP * Integer 可以表現的數字跟平台有關 一般來說都是 4 Bytes 的整數 $int_var = 10 //10 進位 $int_var = 012 // 8 進位 $int_var = 0xa //16 進位 BASIC of PHP * float 在 PHP 中,小數或是實數是以 double 來表示(8 Bytes) $float_var=1.1; $float_var=1.5e2; BASIC of PHP * String 字串是以單引號「’」或是雙引號「”」框住字串。 Example $s=“smaple”; $s2=“$s”; 注意 雙引號內如果有變數,將會用變數內容取代 單引號同一般 C 語言定義 BASIC of PHP * String II 為了區別變數與字串,可以使用 {} 區別 Example $str_z=“$sstring”; $str_z

文档评论(0)

1亿VIP精品文档

相关文档