PHP DOCTYPE html head meta charsetUTF8 titlePHPtitle head
- Slides: 24
第一個PHP 程式 <!DOCTYPE html> <head> <meta charset="UTF-8"> <title>第一個PHP</title> </head> <body> <p>Hello My Friend! </p> <? php echo "我的第一個PHP程式 " ; ? > </body> </html>
include() 特殊用法範例 add_include. php內容如下 <? echo "進入 include file " ; return $a+$b ; ? > 1: <html> 2: <title>Include</title> 3: <body> 4: <? php 5: $a=10 ; 6: $b=20 ; 7: $c=include("add_include. php") ; 8: echo "回到主程式 : <br/>" ; 9: echo "A, B二數和是 $c" ; 10: ? > 11: </body> 12: </html>
PHP 資料型態 名稱 型態 範例 Boolean 布林型態 $a = true; Integer 整數型態 $a = 10 ; Float 浮點數型態 $a = 1. 2345 ; String 字串型態 $a = "Hello !!" ; Array 陣列型態 $a[0] = 20 ; Object 物件型態 $a = new Object. Class ; Resource 外部資源型態 $a = mysql_connect() ; NULL Null型態 $a = NULL ;
Example $str 1 = "I am 16 years old. "; $str 2 = 'I am 16 years old. '; echo "I am 16 years old. <br/>"; echo 'I am 16 years old. <br/>'; echo $str 1. "<br/>"; $age = 18; $str 1 = "I am $age years old. "; $str 2 = 'I am $age years old. '; echo "I am $age years old. ". "<br/>"; // I am 18 years old. echo ' I am $age years old. '. "<br/>"; // I am $age years old.
在字串中{ }之使用 <? php $i=2; $ix='5 x'; echo "$ix+3 y=2$ix"; // 5 x+3 y=25 x echo "<br />"; echo "{$i}x+3 y=2$ix"; //2 x+3 y=25 x ? >
<? php $rt = new table("red"); $gt = new table("black"); $gt->set_color("green"); $rt->show_color(); $gt->show_color(); ? > class table { var $color; function table($cl) { $this->color=$cl; } function set_color($ncl) { $this->color=$ncl; } function show_color() { echo "{$this->color}<br/>"; } } ? > 注意事項: 1. 學習"->"寫法 2. 是$this->color, 不是 $this->$color
PHP 資料型態 NULL型態 ◦ NULL 也是一個比較特殊的型態 ◦ 一個變數如果被設成 NULL,表示這個變數裡沒有任何的值. ◦ 有三種情形會被認定變數的值為NULL (參考下一頁) $n 1=NULL; // or $n 1 = null; $n 2="some text"; unset($n 2); if (is_null($n 1)) echo "$n 1 is null. <br/>"; if (isset($n 2)) echo "$n 2 is set, and $n 2=$n 2. <br/>"; if (empty($n 2)) echo "$n 2 is empty<br/>"; if (!isset($n 3)) echo "$n 3 is not set<br/>"; ? > $n 1 is null. $n 2 is empty. $n 3 is not set.
isset( ), is_null( ), and empty( ) 注意事項: 比較empty()與boolean http: //seanphpbook. blogspot. tw/2009/10/php-empty-isset-php. html
- Doctype html html head
- Canvas доска
- 12.html?title=
- Doctype html html head
- Slidetodoc.com
- Php doctype
- Doctype html example
- Slidetodoc.com
- Doctype html
- Tagi html
- Meta synthesis vs meta analysis
- Meta in html
- Doctype language
- Xhtml
- Php php://input
- Web.facebook.com /profile.php
- Formulario html php
- Php echo html code
- Guest pfp
- Head.php?mod=
- Head.php?index=
- Head.php?corpo=
- Html head body
- Html title head
- Html body section