Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
รายชื่อของนักพัฒนาภาษา PHP • Zeev Suraski, Israel • Andi Gutmans, Israel • Shane Caraveo, Florida USA • Stig Bakken, Norway • Andrey Zmievski, Nebraska USA • Sascha Schumann, Dortmund, Germany • Thies C. Arntzen, Hamburg, Germany • Jim Winstead, Los Angeles, USA • Rasmus Lerdorf, North Carolina, USA
PHP คืออะไร • เป็นภาษา Script สำหรับแสดงเว็บเพจอย่างหนึ่ง จัดอยู่ในกลุ่ม Server Side Script เช่นเดียวกับ ASP • การทำงานจะแทรกอยู่ในเอกสาร HTML • สามารถ Compile ได้ทั้งบนระบบปฏิบัติการ UNIX, Windows NT, Windows 9x • ความสามารถในการทำงานสูง โดยเฉพาะกับการติดต่อกับ Database เช่น MySQL, mSQL, Sybase และ PostgreSQL เป็นต้น
สิ่งที่ PHP สามารถทำได้้ • CGI • Database-enable web page • Database Adabas D InterBaseSolid DBasemSQL Sybase Empress MySQL Velocis FilePro Oracle Unix dbm Informix PostgreSQL
ทำไม PHP จึงเป็นที่นิยม • Open source • No cost implementation – PHP เป็นของฟรี • Server side • Open Source • Crossable Platform • HTML embedded • Simple language
ทำไม PHP จึงเป็นที่นิยม • Efficiency– • XML parsing • Server side • Database module • File I/O • Text processing • Image processing
การทำงานของ PHP • ทำงานบน Server • ทำงานร่วมกับเอกสาร html • สามารถแทรกคำสั่ง PHP ได้ตามที่ต้องการลงในเอกสาร html • ทำงานในส่วนที่เป็นคำสั่งของ PHP ก่อน เมื่อมีการเรียกใช้เอกสารนั้น ๆ • แสดงผลออกทาง Web Browsers
โครงสร้างภาษา PHP • แบบที่ 1 XML style <?php คำสั่งภาษา PHP ?> ตัวอย่าง <?php echo “Hello ! World ! <br>”; echo “I am PHP”; ?>
ตัวอย่างที่ 4 (ต่อ) /* ** print message about lunch cost */ print("$YourName, you will be out "); print($CostOfLunch * $DaysBuyingLunch); print(" dollars this week.<BR>\n"); ?> </BODY> </HTML>
ตัวอย่างที่ 5 intro-5.php3 <? echo '<pre>First Paragraph: Corporal Carrot, Ankh-Morpork City Guard (Night Watch), sat down in his nightshirt, took up his pencil, sucked the end for a moment, and then wrote:</pre>'; ?>
First Paragraph: Corporal Carrot, Ankh-Morpork City Guard (Night Watch), sat down in his nightshirt, took up his pencil, sucked the end for a moment, and then wrote:
<? /* ** print today’s date */ print("<H3>$Today</H3>\n"); /* ** print message about lunch cost */ print("$YourName, you will be out "); print($CostOfLunch * $DaysBuyingLunch); print(" dollars this week.<BR>\n"); ?> </BODY> </HTML>
<HTML> <HEAD> <TITLE>Figure 1–6</TITLE> </HEAD> <BODY> <H1> <? /* ** get today’s day of the week */ $Today = date("l"); if($Today == "Friday") { print("Thank Goodness It’s Friday!"); } else { print("Today is $Today."); } ?> </H1> </BODY> </HTML>
<HTML> <HEAD> <TITLE>Example–7</TITLE> </HEAD> <BODY> <H1>Today’s Daily Affirmation</H1> Repeat three times:<BR> <? for($count = 1; $count <= 3; $count++) { print("<B>$count</B> I’m good enough, "); print("I’m smart enough, "); print("and, doggone it, people like me!<BR>\n"); } ?> </BODY> </HTML>
Escaped characters \n newline \r carriage \t horizontal tab \\ backslash \$ dollar sign \" double-quote \0nnn any octal byte \xnn any hexadecimal byte \\ backslash
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP IF • โครงสร้าง if (expr) statement; • การทำงาน PHP จะ execute statement เมื่อ expr เป็นจริง นอกจากนั้นหากต้องการให้ทำมากกว่า 1 statement ก็สามารถทำได้โดยใส่ { } คร่อม statements
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP IF (ต่อ) • ตัวอย่าง if ($x != $y) print "$x is not equal to $y"; ถ้าค่าเริ่มต้นเป็น $x = 1 และ $y = 1 เมื่อ execute คำสั่งแล้วจะไม่มีการแสดงผลใด ๆ ทั้งนี้เพราะเงื่อนไขของ if เป็นเท็จแต่ถ้าหากว่าค่าเริ่มต้นเป็น $x = 10 และ $y = 2 จะได้ผลลัพธ์จากการ execute เป็น 10 is not equal to 2
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP Else • โครงสร้าง if (expr) statement1; else statement2;
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP Else (ต่อ) • โครงสร้าง if (expr) { statement1; statement2; } else{ statement3; statement4; }
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP Else (ต่อ) • ตัวอย่าง if ($x > $y) { print "$x is greater than $y"; } else{ print "$x is not greater than $y"; }จะได้ว่า statement ของ else จะถูก execute ก็ต่อเมื่อเงื่อนไขของ if เป็นเท็จ นั่นคือ $x มีค่าน้อยกว่า หรือ เท่ากับ $y
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP If () : … endif; • การใช้ code PHP ควบคุมการแสดง code HTML โดยใช้ IF • โครงสร้าง <?php if (expr): ?> HTML CODE <?php endif; ?> • การทำงาน - ตรวจสอบ expr ถ้าเป็นจริงจะแสดง HTML CODE - เป็นเท็จ ไม่แสดงอะไร
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP If () : … endif; • การใช้ code PHP ควบคุมการแสดง code HTML โดยใช้ else และelseif • โครงสร้าง <?php if (expr1): ?> HTML CODE1 <?php elseif (expr2): ?> HTML CODE2 <?php else: ?> HTML CODE3 <?php endif; ?>
Control Structures คำสั่งที่ใช้ในการควบคุมของ PHP While • โครงสร้าง while (expr)statement • การทำงาน while จะcheck เงื่อนไข expr ก่อนที่จะ process statement ที่อยู่ใน block ของ while
Connexion au compte
Connectez-vous pour publier votre contenu sur SlideServe.