Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 3813 Intro to Internet Computing Prof. Roy Levow PHP.

Similar presentations


Presentation on theme: "COP 3813 Intro to Internet Computing Prof. Roy Levow PHP."— Presentation transcript:

1 COP 3813 Intro to Internet Computing Prof. Roy Levow PHP

2 PHP  PHP: Hypertext Processor  Server-side scripting –Script embedded in html –Script runs on server –Allows secure access to resources on server – database, file, etc. –Hides program code from users –But, more network traffic –Standard extension is.php

3 Basic Format …

4 PHP File Form  Script is embedded in HTML  Bounded by and  Bounded by  Output replaces script code in page sent to client

5 PHP Service  Must be installed on server  Enabled in web server  Versions for –Apache and IIS –No many platforms  Primary site for PHP www.php.net

6 Free PHP Services  A number of sites offer limited free PHP services  The following site lists several http://www.0php.com/free_PHP_hos ting.php http://www.0php.com/free_PHP_hos ting.php http://www.0php.com/free_PHP_hos ting.php

7 Your PHP Work  You need a place to work with PHP  You may do any of the following provided that the hosting site is publicly accessible –Set up PHP on your own server –Subscribe to a free hosting site –Use any other hosting site

8 Language Resources  Online PHP Manual http://www.php.net/manual/en/  Tutorials –http://www.php.net/links.php#tutorials http://www.php.net/links.php#tutorials –http://www.w3schools.com http://www.w3schools.com –Google for many others

9 Variables  Names begin with $ followed by string of letters and digits  Case sensitive  No declarations  Type determined by value $num = 5; $myName = “Prof. Levow”

10 Named Constants  define(“ONE”, 1); –do not have $ –must be scalars

11 Types  int, integer  fload, double  string //enclosed in ‘ or “  bool, Boolean //true or false  array //actually a map  object // for O-O programming  NULL //no value

12 Constants  Typical rules for numbers and strings  Usual \ escapes in strings  settype($var, “type”) –function to change type of a value –actually changes type of stored value  (type) expr –typical “C” cast of value  Example: Fig. 26.3, data.php

13 Operators  Comparable to C operators  Usual operators –arithmetic –comparison –logical –increment and decrement  op=

14 String Operators . for concatenation  variable interpolation with “ “ –embedded variable reference is replaced by value –example: “My name is $name.”  numeric valued strings converted for arithmetic –7 + “3” yields 10

15 Regular Expressions  Pattern matching in strings –ereg, eregi  (reg_exp, $search, $match) –Meta characters: * + ? ^ $. –Character class [list]  a-z  :alpha:, :alnum:, :digit:, :space:, :lower:, :upper: –Repetition: {n}, {m,n}, {,n}

16 Environment  Server and Client Side –$_SERVER –$_ENV –$_GET –$_POST –$_COOKIE –$GLOBALS

17 Form Processing  Examples: –fig 26.13 form.html –fig 26.14 form.php  Login –Example:  fig 26.15 password.html  fig 26.16 password.php

18 PHP Examples  Cookies –fig 26.20 cookies.html –fig 26.21 readCookie.php  PHP and Database connectivity


Download ppt "COP 3813 Intro to Internet Computing Prof. Roy Levow PHP."

Similar presentations


Ads by Google