Your SlideShare is downloading. ×
Session1+2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
480
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PHP ? ก F Web Server PHP ˈ C based language F ก F PHP ก F ก Web Browser F Internet Explorer, Fire Fox, Safari ˈWeb Browser F Internet Explorer, Fire Fox, Safari ˈ F Web Site ก F Yahoo Google ก F PHP ก Web Server F F F PHP ก Web Site ก ก PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 2. Call PHP Program By Web Browser ก ก hello.php F 127.0.0.1 F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 3. Run PHP on PC Windows OS Appserv = PHP + Apache + MySQL Apache ก ก Web Server ( F ก ˈ Web Server) PHP Compiler .php filePHP Compiler .php file (Source Code) MySQL ก ก F F Notpad++ ก .php file PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 4. AppservInstallation F F F ก ʽ ก Web Browser ก localhost F F ก Flocalhost F F ก F Start > All Programs > Appserv > Control Server By Service > Apache Restart PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 5. Hello World 1. F Folder C:AppServwww ก Source Code Folder myPHP 2. F Notepad++ F .php file F index.phpF F F 3. Code <?php echo ‘Hello World’; ?> 4. ʽ ก Web Browser F http://localhost/myPHP PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 6. PHP Code Structure F F tag <?php ?> C based language F F ; <?php<?php ……; ……; ……; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 7. PHP Output String F echo “……”; Webbrowser F F ก F F F <br /> F F <?php<?php echo “Hello <br />”; echo “World”; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 8. PHPString Variable PHP F F $ Case Sensitive F F F ก F กF ก <?php $str=“A” echo $str; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 9. PHP String Variable ก F <?php $str1=“A”;$str1=“A”; $str2=“B”; $str3=$str1.$str2; echo $str3; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 10. PHP String Variable F string F F “…..” F F F ก F “ string F F ” F echo “””; F F F ก F $ stringF F F ก F $ string F F $ F echo $ F /*……*/ F ก F F // F ก PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 11. PHP String Variable <?php $str="String"; echo "$str="String"";echo "$str="String""; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 12. PHP Numeric Variable F F F F “…” <?php $num=1; echo $num;echo $num; ?> ก F F echo ก ˈ F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 13. PHP Numeric Variable PHP ˈ C based language ก F C F กF +,- ,*,/,(,),++,--,+= PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 14. PHP Automatic Type Conversion Numeric to String <?php $str1=“I am ”; $str2=“ years old.”;$str2=“ years old.”; $num=20*2; echo $str1.$num.$str2; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 15. PHP Automatic Type Conversion String To Numeric <?php $str_num=“0.5”; $num=0.5; $sum=$str_num+$num; echo “Sumation is ”.$sum;echo “Sumation is ”.$sum; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 16. PHP Automatic Type Conversion F F ก F F Numeric String F F “ . ” F F ก F ˈ ก F string string ก, , , F F F ก F ˈ ก F string ก, , , F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 17. PHP Array Variable ก F ˈ Array F F [] F index( F Array) <?php $arr[0]=1;$arr[0]=1; $arr[1]="a"; echo $arr[0].$arr[1]; ?> ก F Array ก ก F ก F ก F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 18. PHP Array Variable Count F F Array F ก Fก F F F count() <?php $arr[1]="First array";$arr[1]="First array"; $arr[2]="Second array"; echo "Variable arr has ".count($arr)."items."; ?> ก F F Array F 1 F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 19. PHP Logical Operation C based language >, >=,<,<=,==, != && ,|| <?php $true=1;$true=1; $false=0; echo $true>=$false; echo $true||$false; echo $true!=$false; echo $true&&$false; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 20. PHP Logical Operation <?php $n=1.5; $n2="1.5";$n2="1.5"; echo $n==$n2; ?> F ก F ก F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 21. Control Statement if( logical operation) { ……;} else if(logical operation) { ……;} else { ……;} else { ……;} F logical operation ˈ 1 { } F F logical operation F ˈ 1 else PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 22. Control Statement <?php $var="123";$var2=456; if($var==123){echo "$var=123";}if($var==123){echo "$var=123";} echo "<br />"; if($var==$var2){echo "$var=$var2";} else{echo "$var not equal $var2";} ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 23. Control Statement while (logical operation){ …..;} ก {} logical operation F ˈ 1 PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 24. Counter Program ก <?php $n=1; /* count 1 to 10*//* count 1 to 10*/ while($n<=10) { echo $n."<br />"; $n++; } ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 25. Example ก F F F while loop 12345 12345 1234512345 12345 12345 PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 26. Loop And Array Variable ก F Array F Items F Loop while <?php $arr[1]="1"; $arr[2]="2"; $arr[3]="3";$arr[3]="3"; $n=1; while($n<=count($arr)) { echo $arr[$n]."<br />"; $n++; } ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 27. For Loop for(ก F F ; F ก F loop; F F F loop) { …..;…..; …..; } PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 28. For Loop <?php for($n=1;$n<=10;$n++) { echo $n.”<br />”;echo $n.”<br />”; } ?> $n=1 ก ก F F $n<=10 F ก F loop $n++ F F F loop PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 29. For Loop And Array Variable ก F Array F Items F Loop while <?php $arr[1]="1"; $arr[2]="2"; $arr[3]="3";$arr[3]="3"; for($n=1;$n<=count($arr);$n++) { echo $arr[$n]."<br />"; } ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 30. SessionSession PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 31. Session ◦ Session F ก F F F F F ◦ ก F F F a.php F ก F session F F b.php ก F F session F a.php F ก F F กF ก ◦ ก F F F ʽ F F web browser ก ◦ ก F F F a.php F F session F F ʽ F F web browser session F ʽ F F web browser ก F b.php ก F b.php ก F F session ก F a.php F F ก PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 32. Session ◦ F ก session ก ก F F F ก Fก ก ก server ◦ ก ก F session F F ob_start();session_start(); F ก ◦ F F session F F◦ F F session F F $_SESSION[" "] ก F F PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 33. Session F a.php <?php ob_start(); session_start(); $_SESSION[“x”]=1;$_SESSION[“x”]=1; echo $_SESSION[“x”]; $_SESSION[“x”]=“b”; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 34. Session F b.php <?php ob_start(); session_start(); echo $_SESSION[“x”];echo $_SESSION[“x”]; $_SESSION[“x”]=999; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 35. Session F c.php <?php echo $_SESSION[“x”]; ?> PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)
  • 36. ก F • ก F browser PHPH F 2 F ก • header(“Location: file_name url”); • echo “<script>location=‘file_name url’</script>”; • F • header(“Location: index.php”); • header(“Location: home.html”); • header(“Location: http://www.google.co.th”); • echo “<script>location=‘index.php’</script>”; • echo “<script>location=‘home.html’</script>”; • echo “<script>location=‘http://www.google.co.th’</script>”; PROJECTSOFT.BIZ ก WEB APPLICATION F PHP MYSQL AJAX(JQUERY)