PHP Night - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

PHP Night

Description:

Large libraries and repositories of code, free to share ... rs2 = mysql_query('delete from photos where photoID = ''.$photoID. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 17
Provided by: nicholas73
Category:
Tags: php | night

less

Transcript and Presenter's Notes

Title: PHP Night


1
PHP Night
  • March 29, 2005
  • by Nick Barrett

2
What is PHP?
  • Stands for Pre-hypertext processor
  • Primarily a server-side programming language
    (also command-line)
  • Available on nearly every platform
  • Integrates well with a variety of webs servers
    (Apache, Microsoft IIS, etc.)
  • Open-source project started in 1994.
  • Became popular with version 3.0 (now at 5.03)

3
Why learn PHP?
  • Named the 2004 programming language of the year!
  • http//www.tiobe.com/tpci.htm

4
Designed for web development
  • "PHP was built with the needs of Web developers
    in mind... Unlike other cumbersome,
    overhead-laden approaches, PHP is lightweight and
    focused on the Web - where it can solve complex
    problem scenarios quicker and more easily than
    comparable technologies.
  • - Intranet Design Magazine

5
Advantages of PHP
  • Extremely quick development
  • If it takes about 3 months to code a web
    application in C, then using PHP you can
    develop the same web application in just 4 days!!
    And with Zend optimizer, the speed of execution
    of PHP will be very close to that of equivalent
    C program!!
  • Well-documented
  • Large libraries and repositories of code, free to
    share
  • Very fast execution (considered the fastest
    scripting language)
  • Interacts with nearly any database
  • Oracle, dBase, FrontBase, PostgreSQL, FilePro,
    mSQL, MS-SQL, Sybase, IBM DB2, MySQL, ODBC,
    basically anything!

6
Disadvantages of PHP
  • Error-handling
  • Debugging
  • Older versions have only partial support of
    object-oriented features
  • No client-side processing

7
Syntax
  • C-style language
  • If youve done Java, C, or JavaScript
    programming, you will find it very easy.

lt?php include("dbconnect.php") photoID
trim(HTTP_GET_VARS'photoID') rs
mysql_query("select from photos where photoID
'".photoID."'") row mysql_fetch_array(rs)
del_orig unlink(row'original') del_res
ized unlink(row'resized') del_thumbnail
unlink(row'thumbnail') if(del_orig
del_resized del_thumbnail) rs2
mysql_query("delete from photos where photoID
'".photoID."'") echo 'ltscript
language"JavaScriptgt' echo
' history.go(-1)' echo 'lt/scriptgt' ?gt
8
Data types
  • There are 8 primitive data types
  • Boolean (true/false)
  • Integer (3, 5, 1242)
  • Float (0.32, 3.14259)
  • String (ASM, Marriott School)
  • Array (5, 3, 5, Apples, 5, true)
  • Object
  • Resource
  • NULL

9
Objects
  • lt?phpclass Cart    var items  // Items in
    our shopping cart   // Add num articles of
    artnr to the cart   function add_item(artnr,
    num)        this-gtitemsartnr num  
       // Take num articles of artnr out of the
    cart   function remove_item(artnr, num)     
      if (this-gtitemsartnr gt num)           
    this-gtitemsartnr - num           return
    true       elseif (this-gtitemsartnr
    num)            unset(this-gtitemsartnr)  
            return true       else           
    return false         
  • ?gt

10
Variables
  • PHP does not require explicit type definition
    when declaring variablesthe type is determined
    by the context!
  • Very useful when creating code and reusing
    variables
  • lt?php
  • foo "0"  // foo is string
  • foo 2   // foo is now an integer (2)
  • foo foo 1.3  // foo is now a float
  • foo true // foo is now a boolean
  • foo array(4, 2, 5) // foo is now an array!
  • ?gt

11
Control structures
  • If/Else statements
  • For loops
  • While loops
  • For each loops
  • Switch statements

12
Processing web-based data
  • List of global variables from phpinfo()
  • http//128.187.110.210/info.php
  • GET and POST arrays
  • _GET is a global array of variables passed in
    via the URL (page.php?variablevalue)
  • _POST is a global array created by the web
    server when a form is sent via the POST method

13
Development Environments
  • Dreamweaver MX 2004
  • Eclipse 3.0
  • PHP Coder
  • Notepad
  • Lots of other free and commercial products.

14
Examples
  • Hello world
  • Form handling
  • Interacting with a MySQL database
  • Authentication system (sessions)
  • Advanced topics
  • Content management systems
  • Object-oriented design
  • Image editing

15
Online Resources
  • THE place to go www.php.net/docs.php
  • Installing PHP 4 with Apache on Windows
  • Installing PHP 5 with Apache 2.0 on Windows
  • Great overall tutorial on getting started with
    beginning/intermediate PHP

16
Books
Write a Comment
User Comments (0)
About PowerShow.com