PHP HTML script tag script languagePHP PHP fragment
- Slides: 68
การเขยน PHP แทรกอยกบ รปแบบ HTML script tag <script language="PHP"> PHP fragment <? php ? > PHP fragment ยอ <? ? > Expression tag <? = ? > ASP style <% %> HTML 5
HTML script tag <script language="PHP"> php_instructions </script>
ตวอยางการใช <script> tag <html> <head> <title><script language="PHP">echo "Hello world"</script></title> </head> <script language=“PHP”> echo "<h 1>First PHP Example</h 1>n"; echo "Welcome to PHP programming. "; echo "Today : ", date("r"), " (server time) "; echo "<p align=center><a href=index. html>Home</a>n<hr>"; echo "<div align="right">PHP. example by Sumet Angkasirikul"; </script> </html>
PHP. fragment <? php_instructions ? >
ตวอยาง <? php ? > fragment <html> <head> <title><? php echo "Hello world" ? ></title> </head> <? php echo "<h 1>First PHP Example</h 1>n"; echo "Welcome to PHP programming. "; echo "Today : ", date("r"), " (server time) "; echo "<p align=center><a href=index. html>Home</a>n<hr>"; echo "<div align="right">PHP. example by Sumet Angkasirikul"; ? > </html>
PHP fragment แบบสน <? php_instructions ? >
ตวอยางการใช <? ? > tag <html> <head> <title><? echo “Hello world” ? ></title> </head> <? echo "<h 1>First PHP Example</h 1>n"; echo "Welcome to PHP programming. "; echo "Today : ", date("r"), " (server time) "; echo "<p align=center><a href=index. html>Home</a>n<hr>"; echo "<div align="right">PHP. example by Sumet Angkasirikul"; ? > </html>
ตวอยางการใช <? = ? > tag <html> <head> <title><? = "Hello World" ? ></title> </head> <body> <h 1><? = "First PHP Example" ? ></h 1> Welcome to PHP programming. Today : <? = date("r")? > (server time) <p align=center><a href=<? = "index. html" ? >>Home</a><hr> <div align="right">PHP. example by Sumet Angkasirikul</div> </body> </html>
ผลลพธทสงกลบ Browser <html> <head> <title>PHP Example by Aj. Sumet : example 2 -1. 1 a</title> </head> <body> <h 1>First PHP Example</h 1> Welcome to PHP programming. Today : Sat, 26 Feb 0700+ 13: 51: 46 2005 )server time) <p align=center><a href=index. html>Home</a> <hr><div align="right">PHP. example by Sumet Angkasirikul</body> </html>
ตวอยางการใช white space <? $user. Name = “Arnold Palmer” ; $user. Title = “The Premier”; $printed. Title = $user. Name. “ : “. $user. Title ; echo $printed. Title ? >
ตวอยางการใช echo <Html> echo $lucky. No; <head> echo " "; <title>Example 2. 1. 1 a Echo</title> echo "Time now : ". date("r"). ". n" ; </head> echo "See you, Bye. " <body> ? > <? </body> $lucky. No = 9; echo "Hello world. "; echo "This is echo example. n"; echo "Lucky no. is "; </html>
ผลลพธบนจอเวบบราวเซอร Hello world. This is echo example. Lucky no. is 9 Time now : Mon, 8 Nov. 0700+ 23: 28: 23 2004 See you, Bye.
Source code ภาษา html <Html> <head> <title>Example 2. 1. 1 a Echo</title> </head> <body> Hello world. This is echo example. Lucky no. is 9 Time now : Mon, 8 Nov. 0700+ 23: 32: 04 2004 See you, Bye. </body> </html>
ผลลพธ HTML <Html> <head> <meta http-equiv="Content-Type" content="text/html; charset=tis-"620> <title>PHP Example by Aj. Sumet : example 2. 1. 2 -2</title> </head> <body> ตวเลข รายรบ 307200 บาท รายจาย 92160 บาท คงเหลอสทธ 215040 บาท สวสด </body> </html>
ตวอยาง <? /* Example 2. 1. 2 a : Comment example. /* # this is 1 st php code fragment $title. Msg=“Example 2. 1. 2 a : comment”; $hello = “Hello world”; ? > <HTML> <head> <title><? echo $title. Msg; // send out title message from var. ? ></title> </head> <body> <h 1><? = $hello; // Just send out hello world to browser ? ></h 1> </body> </html>
ชอ identifier Case-sensitive ยกเวน standard function ไมมขอจำกดดานความยาว ไมซำกบ Reserved word ของ PHP
ตวอยางการตงชอทถกตอง Score user. Account Address 01 วนทปอน last_modified_date valid. Account
ชนดขอมล Boolean Integer Float/double String Array Object Resource Null
Floating Point Literal ตวเลขทศนยม -589. 25 , 8009887. 1258 , 0. 001547 Scientific notation 25. 8 e-6 , -0. 0147 e-8 , 5. 0 e 16
String Literal (double quote) Multiple line $a = “This is a long message. We can extend this message to multiple line. ” Embedded variable $user 1 = “Arnold”; $est. Yr = 1958; $hello = “Member $user 1, Welcome”; //result: Member Arnold, Welcome $est. Msg = “Our organization was established in $est. Yr. ”
String Literal (double quote) Embedded variable $user 1 = “Arnold”; $est. Yr = 1958; $hello = “Member $user 1, Welcome”; //result: Member Arnold, Welcome $est. Msg = “Our organization was established in $est. Yr. ” $msg = “Item no. {$item[2]} : quantity {$order->quan} : status OK”
ตวอยางการใชตวแปร <? /* Example 2. 1. 3 a : variable */ $a = 3200; $b = 7; $c = $a * $b / 100; ? > <html> <head><title> Example 2. 1. 3 a : variable usage. </title></head> <body> <p><u>Example 2. 1. 3</u> <p><? = “$a * $b % = $c” ? > <p><? = “The value of variable D is now $d“ // $d is not declared? > </body>
Type casting operator (type) expression เชน $quan = (int) $mquan; คำทใชกำหนดชอ boolean หรอ bool int หรอ integer float / double หรอ real string, array, object type
Type casting function settype(expression, type ) ตวอยาง $quan = settype($mquan, ”integer”);
การแปลงเปน array จาก Boolean, integer, float, string, resource ใหเปน array จะได array 1 element ทม index เปน [0[ จาก object จะได associative array ทม string ตามชอ variable ของ object index เปน
Operators Mathematics +, -, *, /, % (modulus) Assignment =, +=, -=, *=, /=, %=, . = Incremental/decremental ++, -- (++pre/post++)
Operators Bitwise • &, |, ^, ~, << (shift left), >> (shift right) Comparison • ==, !=, >, >=, <, <=, ) ===equal value & same type==! , ( Logical • AND &&, OR ||, ! การทำงานของ expression เปนแบบ short-circuit
Operators Conditional operator condition? expr 1: expr 2 $a=$y>1970? ”pass”: ”too young”; Error control @ if(@fopen(“user. dat”, ”r”)) { … } String concatnate . $a = $b. “ baht”;
Functions Standard / Predefined functions • ภาษา PHP ม function เปนกลมตางๆ นบรอยกลม มจำนวนนบพนฟงกชน ด PHP Manual User defined functions Function call • function. Identifier([arguments]) $a= round($b*20); echo “Password : “. str_repeat(“x”, $n); $now = time();
- Php fragment
- Gniazdo labedzia niemego majace postac
- Action tag and dialogue tag
- Jeden morgen beginnt ein neuer tag
- Guten tag guten tag hallo wie gehts
- Html tags
- Font color html
- About question tag
- Fungsi tag pada html
- Yang merupakan root atau induk dari seluruh tag html adalah
- Les questions tags
- Note tag in html
- Html new line tag
- Horizontal line
- Html applet tag
- Body tag attributes
- Itialic
- Bhtml?title=
- Doctype html html head
- 12.html?title=
- Html
- Head body html
- /html/body/script[1]
- Scoring a script
- Script html head
- Script html
- Inside which html element
- $1 bash
- Php doctype html
- Formulario html php
- Echo html code
- Php script
- Script php
- Php php://input
- Web.facebook.com /profile.php
- Dfd fragments examples
- Sentence fragment jeopardy
- Sentence fragment definition
- Chaput fragment ankle
- Fragment program
- Fragment paragraph
- Dusty plasma radiator
- Sentence fragment identifier
- Types of restriction endonucleases
- Perseus core fragment a
- What does fragment mean in writing
- Lens fragment
- Whats a fragment sentence
- Rhetorical fragment
- How is selective breeding accomplished
- Fragments used in a sentence
- Protein fragment complementation assay
- Fragment 2 for composition vii, 1913.
- Fragment sentence
- Okazaki fragment
- Dfd fragment
- Fragment offset
- Effective fragment potential
- Sentence fragment
- Treceti urmatorul fragment dialogat în vorbire indirectă
- Topic sentence
- Ingres algorithm
- Whats a fragment sentence
- Dfd ch5
- What is a fragment
- Restriction fragment length polymorphism
- A sentence fragment may be corrected by
- Sentence vs fragment
- Restriction fragment length polymorphism