SlideShare a Scribd company logo
PHP Programming
Application


 FTP         Telnet            WWW                  DNS
Server       Server            Server              Server
  TCP Port                          TCP Port :80    TCP Port :53
                TCP Port :23
  20,21
             Windows socket Interface

                                                      Host to Host
                TCP                      UDP

                                                            Internet
                               IP
                                                            Network
Application Layer
การทำางานของโปรโตคอลชันนี้จะเป็นการ
                              ้
  เข้าใช้ทรัพยากร
ระยะไกล (Remote Access) และการแชร์ใช้
  ทรัพยากร
HTTP (Hyper Text Transfer Protocol)
(Resource บส่งไฟล์เว็บเพจ ระหว่างเว็บบราวเซอร์
ใช้สำาหรับการรั Sharing) โปรโตคอลที่อยู่ใน
และเว็บเซิรนี้ได้แก่
  Layer ์ฟเวอร์
SMTP (Simple Mail Transfer Protocol)
ใช้สำาหรับการรับส่งอีเมล์ระหว่างเมล์เซอร์เวอร์
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
Application Layer
FTP (File Transfer Protocol)

  ใช้สำำหรับกำรถ่ำยโอนไฟล์ระหว่ำงโฮสต์ทำำได้
  เฉพำะสมำชิกเท่ำนัน้
กำรบริกำรอยู่ 2 ประเภท คือ Private FTP / เฉพำะ
  กลุ่ม
นิยมใช้ตำมสถำนศึกษำและภำยในบริษัท ผู้ใช้
  บริกำร
จะต้องมีรหัสผ่ำนเฉพำะจึงจะใช้งำนได้
ประเภทที่สองคือ Anonymous FTP/FTP
  สำธำรณะให้บริกำร
ดำวน์โหลดไฟล์ข้อมูลฟรีโดยไม่ตองมีรหัสผ่ำน ซึ่ง
                               ้
Web Server
เว็บเซิรฟเวอร์ (Web Server) คืออะไร
        ์
     เครื่องบริการเว็บไซต์ หรือเว็บเพจผ่าน http://.. .. ..
    เพื่อให้ได้ข้อมูลทั้งภาพ เสียงจาก
ผูให้บริการ เช่นบริการ http://www.google.com ที่เปิด
  ้
    บริการเว็บจากเครื่องให้บริการที่
เรียกว่า Web Server สำาหรับบทความ หรือข้อมูลในหน้านี้
    ให้ข้อมูลเกี่ยวกับการทำา
Web Server ด้วย โปรแกรมต่าง ๆ Web Server ที่เป็นที่
    นิยมได้แก่ PWS, IIS และ Apache
    บริการเว็บเซิร์ฟเวอร์ จะมีบริการเสริมต่าง ๆ สำาหรับนัก
    พัฒนา ที่ทำาให้เว็บไซต์
Apache คืออะไร
 Apache คือ โปรแกรม ที่ทำาหน้าที่เป็น web
 server ที่มีผู้ใช้ทั่วโลกมากกว่า 60 % มีหน้าที่
 ในการจัดเก็บ Homepage และส่ง Homepage
 ไปยัง Browser ที่มีการเรียกเข้า ยัง Web
 server ที่เก็บ HomePage นันอยู่ซึ่งปัจจุบนจัด
                               ้            ั
 ได้ว่าเป็น web server ที่มี ความน่าเชื่อถือมาก
 ซึ่งสามารถหามา Download ได้จาก website
 www.apache.org
Web Architecture
                                 Apache
                                Web Server
TCP/IP Port:80
Via Web Brower
                     TCP/IP
                     Port:80

           Interne
           t                           TCP/IP
                                       Port:3306




                               Data base MySQL
Web Architecture (3)
                                                                Apache
                             Get / Post                       Web Server
 Web          HTML                                              include
Brower      Document                                          Php engine




         MySQL Database


                             TCP/IP           PHP
                            Port:3306       Document



          Grant Allow for                 Php Configuration
           Connect via                          with
         Apache and PHP                    MySQL Library
Apache + PHP + Mysql
   การจะติดตั้ง Apache webserver และจะรู้สึกว่าเป็นภาระหนัก
   ยิ่งขึน หากเราต้องการเพิ่ม
         ้
MySQL, PHP และ Perl เข้าไปด้วย ปัจจุบันเราไม่ตองลงแรง
                                                 ้
   ขนาดนั้น เนื่องจากในโลกของ
ชุมชนนักพัฒนาจะมีโปรแกรมจำาลองเครื่องพีซให้เป็นเวบเซอร์ฟ
                                           ี
   เวอร์ได้อย่างง่ายดาย
โปรแกรม XAMPP เป็นหนึ่งในโปรแกรมยอดนิยมที่นักพัฒนานำา
   มาใช้กัน
   XAMPP ได้รวบรวม package ต่าง ๆ ไว้ เพื่อลดความยุ่งยาก
   ในการติดตั้ง package ต่าง ๆ ที่
ใช้ในการทำา webserver ซึงภายในโปรแกรมจะประกอบไปด้วย
                          ่
  Apache, MySQL, PHP + PEAR, Perl,
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
xampp-win32-1.4.15-installer
http://localhost/
Getting Start
Web Root
Introduction for PHP
ใช้ในกำรเปิดและปิด Script ที่เขียน
 ด้วย PHP
 <?PHP
    …..
 ?>
               หรือ
 <?
    …..
Introduction for PHP
PHP: Hypertext Preprocessor

  <html>
    <head>
      <title>Example</title>
    </head>
    <body>
    Say by HTML <br>
     <?php
     echo "Hi, I'm a PHP script!";
      ?>
     </body>
  </html>
Introduction for PHP
 ทำาการแสดงผลเป็นเอกสารรูปแบบ   HTML
 Document
 <html>
   <head>
     <title>Example</title>
   </head>
   <body>
   Say by HTML <br>
   Hi, I'm a PHP script!
    </body>
 </html>
Introduction for PHP
Function print() and echo()
 การแสดงผลข้อมูล/ ข้อมูล

            print “Hello”;
            echo “Hello”;

            หรือ

            print (“Hello”);
            echo (“Hello”);
กำรเขียนหมำยเหตุให้กับโปรแกรม (Comment)

   แบบบรรทัดเดียว
     // ข้อความ
     # ข้อความ

   แบบหลำยบรรทัด
     /*
     ข้อความบรรทัดที่ 1
     ข้อความบรรทัดที่ 2
     */
Show all predefined variables
        with phpinfo()
<?php phpinfo(); ?>   phpinfo.php
Workshop ที่ 1
 ftp://sec3@rider
 สร้าง folder ด้วยรหัสนักศึกษา
 สร้าง file ชื่อ index.php
     <HTML>
     <HEAD>
     <TITLE> 48111111111</TITLE>
     </HEAD>
     <BODY>
     <h1> 48111111111</h1>
       Hello form HTML<br>
     <?
          for ($i = 0 ;$i < 5 ; $i++) {
            echo “Hi, PHP Script. <br>”;
         }
     ?>
     </BODY>
     </HTML>
Workshop ที่ 2
 ftp://sec3@rider
 สร้าง folder ด้วยรหัสนักศึกษา
 สร้าง file ชื่อ info.php

    <HTML>
    <HEAD>
    <TITLE> 48111111111</TITLE>
    </HEAD>
    <BODY>
    <?
     phpinfo();
    ?>
    </BODY>
    </HTML>
Dealing with Forms
   A simple HTML form
                                              File name :test.php

<form action="action.php" method="post">
        Your name: <input type="text" name="name" /> <br>
        Your age: <input type="text" name="age" /> <br>
       <input type="submit" /> <br>
</form>
                                             File name :action.php
    Hi <?php echo $name; ?>.
    You are <?php echo $age; ?> years old.


    Out put from this script
    Hi Joe. You are 22 years old.
Workshop ที่ 3
  ftp://sec3@rider
  สร้าง folder ด้วยรหัสนักศึกษา
  สร้าง file ชื่อ input.php, print.php
<HTML>
<HEAD>
<TITLE> 48111111111</TITLE>
</HEAD>
<BODY>
<h1> 48111111111</h1>
<FORM METHOD=POST ACTION=“print.php">
  Input your name <INPUT TYPE="text" NAME=“yourname">
</FORM>
</BODY>
</HTML>
                                                    Input.php
print.php




My name is
<? echo $yourname ?> .
Web Architecture
                                                       Apache
                    Get / Post                       Web Server
 Web       HTML                                        include
Brower   Document                                    Php engine




                                     PHP
                                   Document



                                 Php Configuration
                                       with
                                  MySQL Library
โครงสร้างภาษา PHP
PHP จะคล้ายภาษาคอมพิวเตอร์ทั่วไป เช่น C,
    Perl, Java
รูปแบบมีดังนี้
  –   ชนิดข้อมูล (Data Type)
  –   ตัวแปร (Variable)
  –   โอเปอเรเตอร์ (Operator)
  –   ค่าคงที่ (Constants)
  –   เงือนไขเพื่อตัดสินใจ (If…elseif…else, swich…case)
         ่
  –   การทำางานวนรอบ (For, while, Do..while, Foreach)
ตัวแปร (Variables)
1. ชือตัวแปรต้องขึนต้นด้วย $ (Dollar sign)
     ่               ้
    จากนั้นตามด้วยตัวอักษร ตัวเลข หรือสัญลักษณ์
2. สามารถนำาตัวอักษรกับตัวเลขผสมกันได้
   $name_1, $Salary1, $phone
3. ชือตัวแปรไม่สามารถเว้นว่างหรือเคาะเว้นวรรคได้
       ่
4. ควรสื่อความหมายในตัวมันเอง
5. ชือตัวแปร อักษรตัวเล็ก ตัวใหญ่นั้นมีความสำาคัญมาก
         ่
    (case Sensitive)
    เช่น $address, $Address, $ADDRESS
           ถือว่าเป็นตัวแปรคนละตัวกัน
PHP supports 8 primitive types
   4 scalar types
    –   boolean
    –   integer
    –   float (floating-point number, aka 'double')
    –   string
   2 compound types
    – array
    – object
   2 special types
    – resource
    – NULL
boolean
เป็นของมูลที่มีคา 2 ค่าคือ true (ถูก) หรือ false (ผิด)
                ่


          keyword TRUE or FALSE. Both are case-insensitive
integer
ใช้สำำหรับเก็บข้อมูลตัวเลข จำำนวนเต็ม
 เลขฐำนต่ำงๆ
Floating point numbers
ใช้เก็บข้อมูลตัวเลขจำำนวนจริง +,- ที่มทศนิยมและไม่มทศนิยม
                                      ี            ี

                       $a = 1.23; //จำานวนเต็มบวก
                       $a = -1.23; //จำานวนเต็มลบ

                       $a = 1.2e3; // จำานวนเต็มบวกในรูปยกกำาลัง

                                    // 1.2*10^3 =1200

                       $a = -1.2e3; // จำานวนเต็มลบในรูปยกกำาลัง
                                    // - 1.2*10^3 = -1200
Strings
ใช้เก็บข้อมูลตัวอักษรหรือข้อควำม
 “ข้อควำม”
   single quoted
     $str = ‘Example of string’;
   double quoted
     $str = “Example of string”;
   heredoc syntax
     $str = <<<EOD
              Example of string
              spanning multiple lines
              using heredoc syntax.
              EOD;
How to assign to
 string variable
Single quoted
Double quoted
Heredoc
Arrays
ใช้เก็บข้อมูลเป็นชุด หรืออำร์เรย์
กำรกำำหนดตัวแปรจะอยู่ในเครื่องหมำย [….]
Arrays
unset() ใช้ในการยกเลิกค่าของ array
การแสดงค่าใน array
Object
ใช้เก็บข้อมูลเพื่อเรียกกำรใช้ class object และ Functions
Type Juggling
ใช้เก็บข้อมูลในลักษณะเฉพำะหรือผู้
 ใช้เพิ่มเติมเข้ำมำ
PHP Work Shop 3.
   ให้รับข้อมูลจาก form html แล้วทำาการแสดง
    ผลดังนี้
PHP Work Shop 3.
   แสดง output ดังนี้
วีธีการทำา PHP Work Shop 3.
   ทำาการสร้าง file ใน Document root




                       ให้สร้ำง folder ด้วยรหัสนักศึกษำ
                              เช่น 48111111111
วีธีการทำา PHP Work Shop 3.
WorkShop1.php
วีธีการทำา PHP Work Shop 3.
acction.php

More Related Content

PDF
Ftp rss mashup gedget widget ai phishing
PDF
PDF
Php training
PDF
Joomla3 : XAMPP Portable
PDF
PDF
Doc1
Ftp rss mashup gedget widget ai phishing
Php training
Joomla3 : XAMPP Portable
Doc1

What's hot (20)

PPTX
การใช้เครื่องมือต่างๆ1
PPTX
การใช้เครื่องมือต่างๆ
PPTX
การใช้เครื่องมือต่างๆ12
PPTX
การใช้เครื่องมือต่างๆ1
PDF
รายงาน PHP - Know2pro.com
PDF
Doc2
PDF
Cent OS-book
PDF
omeka-portable-startup
PDF
NETWORK SERVICEOPENSSH + NTP + SQUID
PDF
Digital Collection with Omeka
PAGES
คำสั่ง ลินุกซ์ (Linux)
PDF
OAI-PMH with Drupal + XAMPP Portable + PKP OHS
PDF
20110201 drupal-ir
PDF
ความรู้เบื้องต้นเกี่ยวกับภาษาPhp
PDF
Set up rubytech fgs 2924 r กับ tacacs
PPT
เริ่มต้นกับ PHP
PDF
20131116 wordpress-xampp
การใช้เครื่องมือต่างๆ1
การใช้เครื่องมือต่างๆ
การใช้เครื่องมือต่างๆ12
การใช้เครื่องมือต่างๆ1
รายงาน PHP - Know2pro.com
Doc2
Cent OS-book
omeka-portable-startup
NETWORK SERVICEOPENSSH + NTP + SQUID
Digital Collection with Omeka
คำสั่ง ลินุกซ์ (Linux)
OAI-PMH with Drupal + XAMPP Portable + PKP OHS
20110201 drupal-ir
ความรู้เบื้องต้นเกี่ยวกับภาษาPhp
Set up rubytech fgs 2924 r กับ tacacs
เริ่มต้นกับ PHP
20131116 wordpress-xampp
Ad

Viewers also liked (18)

PDF
Criminal penalties2
PPT
Search engine
PDF
Presentation seo
PPT
Blogs and Wikis for Reflection and Collaboration
PDF
PDF
Level One - Unlock Your Career in Manufacturing - Sample
PPT
Control What You Can Control
PDF
Web site
PDF
คู่มือการใช้งาน Google
PDF
อังสุมา ภาระจ่า
PDF
ความรู้เกี่ยวกับ Html
PDF
Samson Manufacturing Case Study (032815)
PPTX
Exemplars
PDF
E-commerceG1-Case3 Amazon
PPT
กฎหมายวิธีพิจารณาความอาญา2
Criminal penalties2
Search engine
Presentation seo
Blogs and Wikis for Reflection and Collaboration
Level One - Unlock Your Career in Manufacturing - Sample
Control What You Can Control
Web site
คู่มือการใช้งาน Google
อังสุมา ภาระจ่า
ความรู้เกี่ยวกับ Html
Samson Manufacturing Case Study (032815)
Exemplars
E-commerceG1-Case3 Amazon
กฎหมายวิธีพิจารณาความอาญา2
Ad

Similar to การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05 (20)

PDF
Introduction to PHP programming
ODP
Greenstone Installation
PPT
PHP Tutorial (introduction)
PDF
PPT
Php beginner
PDF
Best
PDF
รออกแบบเว็บไซต์
PDF
โบ
PDF
หวิว
PDF
หมวย
PDF
หมวย
PDF
ดรีม
PDF
นุ๊ก
PPT
20100806 wordpress-server2 go
PPT
20100806 wordpress-server2 go
PPT
20100806 wordpress-server2 go
PPT
wordpress-server2
Introduction to PHP programming
Greenstone Installation
PHP Tutorial (introduction)
Php beginner
Best
รออกแบบเว็บไซต์
โบ
หวิว
หมวย
หมวย
ดรีม
นุ๊ก
20100806 wordpress-server2 go
20100806 wordpress-server2 go
20100806 wordpress-server2 go
wordpress-server2

More from Jenchoke Tachagomain (20)

PPT
Lab 2 For Css
PPT
Digital Content Business
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 09
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 08
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 07
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 06
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 04
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 03
PPT
Communication Concept
PPT
การพัฒนาเอกสารออนไลน์ขั้นสูง Intro
PPT
Communication Concept 3
PPT
Communication Concept
PPT
Communication Concept
PPT
J2ME Game Concept
PPT
J2ME Game Concept
PPT
Mobile Game and Application with J2ME
PPT
Mobile Game and Application with J2ME - Collision Detection
PPT
Mobile Game and Application with J2ME
PPT
Mobile Game and Application with J2ME
Lab 2 For Css
Digital Content Business
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 09
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 08
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 07
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 06
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 04
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 03
Communication Concept
การพัฒนาเอกสารออนไลน์ขั้นสูง Intro
Communication Concept 3
Communication Concept
Communication Concept
J2ME Game Concept
J2ME Game Concept
Mobile Game and Application with J2ME
Mobile Game and Application with J2ME - Collision Detection
Mobile Game and Application with J2ME
Mobile Game and Application with J2ME

การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05