Intro to PHP Programming Language PHP G PHP

  • Slides: 15
Download presentation
Intro to PHP Programming Language

Intro to PHP Programming Language

PHP G PHP: Hypertext Preprocessor G Scripting language

PHP G PHP: Hypertext Preprocessor G Scripting language

History G 1994 - Written by Rasmus Lerdorf G 1997 - Zeev Suraski and

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

History G 1998 - PHP 3 G 2000 - PHP 4 G Still being

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

Usage G Server-side Scripting G Web development G Command-line Scripting G Shell scripting G

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

Server-side Scripting G Main use G Code embedded in HTML to create dynamic web

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

Syntax G Advantage: Similar to high level Programming Language G PHP code goes between

Syntax G Advantage: Similar to high level Programming Language G PHP code goes between tags G <? php --CODE-- ? > G Features that make it different

Syntax G Embedding HTML in PHP control structures G Will output anything between ?

Syntax G Embedding HTML in PHP control structures G Will output anything between ? > and the next <? php tags

Types G Type is not explicitly set for variable by programmer G Type of

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

Types Eight different types: G Boolean G Integer G Float AKA Double G String

Types Eight different types: G Boolean G Integer G Float AKA Double G String G Array G Object G Resource G Null

Variables G Start with $ G Stores value to be reused G Text G

Variables G Start with $ G Stores value to be reused G Text G Number G Code G Programmer or user defined

Variables G Example: G $name = “Jose Rodriguez”; G $num = 1;

Variables G Example: G $name = “Jose Rodriguez”; G $num = 1;

Operators G G G G == != <> > < >= <= is equal

Operators G G G G == != <> > < >= <= is equal to is not equal is greater than is less than is greater than or equal to is less than or equal to

Operators Example G Define variable $name G $name = “Jose”; G Check against variable

Operators Example G Define variable $name G $name = “Jose”; G Check against variable $username G Name typed by user in form G $name == $username;

References G W 3 Schools G http: //www. w 3 schools. com/php/default. asp G

References G W 3 Schools G http: //www. w 3 schools. com/php/default. asp G PHP Manual G http: //www. php. net/manual/en/index. php