PHP - PowerPoint PPT Presentation

About This Presentation
Title:

PHP

Description:

Scripting language. History. 1994 - Written by Rasmus Lerdorf ... Command-line Scripting. Shell scripting. Client-side GUI Apps. Not very common ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 23
Provided by: joshua47
Learn more at: https://grothoff.org
Category:
Tags: php

less

Transcript and Presenter's Notes

Title: PHP


1
PHP
  • By
  • Sergio Rodriguez

2
PHP
  • PHP Hypertext Preprocessor
  • Scripting language

3
History
  • 1994 - Written by Rasmus Lerdorf
  • 1997 - Zeev Suraski and Andi Gutmans
  • Rewrote parser
  • PHP 2

4
History
  • 1998 - PHP 3
  • 2000 - PHP 4
  • Still being developed
  • Version 4.4.7 - Oct. 2007
  • 2004 - PHP 5

5
Usage
  • Server-side Scripting
  • Web development
  • Command-line Scripting
  • Shell scripting
  • Client-side GUI Apps
  • Not very common

6
Server-side Scripting
  • Main use
  • Code embedded in HTML to create dynamic web pages
  • LAMP Architecture
  • Advantage over others
  • but first!

7
Syntax
  • Advantage Similar to high level PLs we are
    familiar with
  • PHP code goes between tags
  • lt?php --CODE-- ?gt
  • Features that make it different

8
Syntax
  • Embedding HTML in PHP control structures
  • Will output anything between ?gt and the next
    lt?php tags

9
Types
  • Type is not explicitly set for variable by
    programmer
  • Type of variable is juggled throughout PHP code
  • Criticism due to this (errors not detected at
    compile time)

10
Types
  • Eight different types
  • Boolean
  • Integer
  • Float AKA Double
  • String
  • Array
  • Object
  • Resource
  • Null

11
Boolean
  • Trivial
  • Cast as (bool) or (boolean)
  • False is
  • Integer - 0
  • Float - 0.0
  • String - Empty or 0
  • NULL
  • Array - Size 0 among others
  • True is everything else

12
Integer
  • No unsigned integers in PHP
  • Include octal and hexadecimal numbers
  • Octal - 00-7
  • Hex - 0xX0-9a-fA-F
  • Overflow? Treats value as float
  • No division operator - yields float
  • Cast as (int) or (integer)
  • From float to integer - rounding towards zero

13
Float (Double)
  • Loss of precision when converted to internal
    binary
  • Ex floor((0.10.7)10) is 7, not 8
  • Cast as (float), (double), or (real)

14
String
  • No bound to size of strings
  • Single quotes
  • Escape or \ characters
  • Double quotes
  • More escaped characters (\n, \t, \\, etc)

15
Array
  • (key, value) pairs
  • Key may be an integer index, like Java arrays
  • print_r(arr) //Prints out array

16
Object
  • Use new to create new instance
  • Cast as (object) - new instance of built-in class
    stdClass
  • scalar member contains value

17
Resource
  • A resource is a special variable, holding a
    reference to an external resource. Taken from
    the PHP Documentation
  • i.e. Connectors to DBs (mySQL, MSSQL, etc)

18
Variables
  • Start with , followed by underscore or letter,
    and then followed by (number letter
    underscore)
  • Dynamic Scoping
  • Variable variables
  • Hold variable name as string

19
Operators
  • Same as other PLs
  • , !
  • echo shell command
  • . (Yeah, thats it)
  • Arrays
  • , and equality across key/value pairs
  • Instanceof (Looks familiar?)

20
Functions
  • Again, similar to what we already know
  • C-style
  • i.e. function foo(myVal 44)/BODY/
  • return arrays to list
  • Store function name in variable

21
Objects
  • Nothing new
  • parent - used in inheritance, refers to base
    class
  • PHP 5 is more extensive

22
References
  • Wikipedia - PHP
  • http//en.wikipedia.org/wiki/PHP
  • PHP Manual
  • http//www.php.net/manual/en/index.php
Write a Comment
User Comments (0)
About PowerShow.com