php web programming

Download PHP Web Programming

If you can't read please download the document

Upload: muthuselvam-rs

Post on 16-Apr-2017

108.936 views

Category:

Technology


2 download

TRANSCRIPT

Tool Developer (PHP)

INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0

Click to edit the title text format

www.intellibitz.com [email protected]

www.intellibitz.com [email protected]

INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0

Football
Soccer
Hockey
Baseballl
INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0Football
Soccer
Hockey
Baseballl
Drop down box

I like Red I like Blue I like Green

List box

I like chinese food I like mexican food I like American Food I like Italian food

INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0

Assume that you name all your class files in the following scheme. class-{classname.php}the following example shows youhow to make those files automatically loaded.

INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0The pattern ((great)*grand)?((fa|mo)ther) matches any ancestor : father,mother ,grand father,grandmother,great grand father,great grand mother,great great grand father, great great grand mother.INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0INTELLIBITZ TechnologiesPHP Web ProgrammingTD_PHP_V1.0.0IntelliBitz Technologies
Training Division
168, Medavakkam Main Road
Madipakkam, Chennai 91.
PH: +91 044 2247 5106
www.intellibitz.com
[email protected]

PHP WEB
PROGRAMMING.

CHAPTER 1

STARTING WITH PHP.

PHP First Steps - Overview

PHP and the WWW

PHP as a server-side language

What's so great about PHP?

PHP in action

PHP basics

PHP and the Web

www.intellibitz.com Is typed in firefox

Firefox sends a message over the internet to the computer named www.intellibitz.com

Apache, a program running on www.intellibitz.com, gets the message and asks the PHP interpreter, another program running on the www.intellibitz.com computer, what does /index.php look like?

PHP and the Web

The PHP interpreter reads the file /var/www/html/index.php from disk drive

The PHP interpreter runs the commands in index.php, possibly exchanging data with a database program such as MySQL

The PHP interpreter takes the index.php program output and sends it back to Apache as answer

PHP and the Web

Apache sends the page contents it got from the PHP interpreter back to your computer over the Internet in response to Firefox

Firefox displays the page on the screen, following the instructions of the HTML tags in the page

PHP a server-side language

PHP runs on the web server

Javascript and Flash in contrast, are client-side because they run on a web client

The instructions in a PHP program cause the PHP interpreter on a web server to output a web page. The instructions in Javascript cause Firefox to run browser commands.

What's So Great About PHP?

PHP is free

PHP is cross-platform

PHP is widely used

PHP hides its complexity

PHP is built for Web Programming

PHP in action

The PHP interpreter runs the commands between tags

PHP processing form data via $_POST

String syntax called a 'here document'

Using PHP internal library functions like number_format ()

Displaying infromation from a database

Basic Rules of PHP Programs

Start and End Tags

Whitespace and Case-Sensitivity

Comments

Chapter Summary

PHP's usage by a web server to create a response to send back to browser

PHP as a server-side language, contrasting with a Javascript a client-side language

PHP is free, cross-platform, widely-used

PHP basics, program structure, process form, and talk to databases

CHAPTER 2

TEXT AND NUMBERS

Working with Text and Numbers

Defining Text Strings

Validating and formatting text

Manipulating Text

Numbers

Arithmetic Operators

Variables

Putting variables inside strings

Text

Pieces of text are called strings

String can even contain binary file such as image or sound

String is surrounded by a single quotes.. single quotes are delimiters

Backslash \ to be used for escaping

The escape character can itself be escaped

Defining Text Strings

Variable names in a double-quoted string will be substituted with its value.This is called as variable interpolation.

Here documents obey the same escape-character and variable substitution rules

Use a . (period) to combine two strings.The . is the cancatenation.

Manipulating Text

Validating string using trim () and strlen ()

To compare two strings, use the equality operator (==)

Use strcasecmp () to compare strings ignoring case

Formatting Text

Use printf () with a format string and the items to print

Zero-padding, displaying signs with printf ()

Use of strtolower (), strtoupper (), ucwords (),ucfirst() substr (), str_replace ()

String Functions.

$length = strlen($string);

$arrayStr = explode($separator,$string);

$str = implode($separator,$arrayStr);

$trimStr = trim($string);

$resultStr = str_replace($old,$new,$full);

Join() alias of implode().

String Functions

$padded = str_pad ($string,$length)

The returned string is atleast $length characters long.

$repeat = str_repeat($string,$n)

$string is repeated $n times and returned as string.

$array= str_split($string);

This function returns an array comprising the characters that make up the string.

str_word_count

Return information about words used in a string

String functions

$substring = substr($string,$n,$length)

The portion of the string starting from the $n th character for $length number of character is returned.

If $n is negative the substring wil start that many characters from end of the string.

If $length is negative ,that many characters will be omitted from end of the string.

String functions

substr_compare

int substr_compare ( string $main_str, string $str, int $offset [, int $length [, bool $case_insensitivity]] )

substr_compare() compares main_str from position offset with str up to length characters.

Returns < 0 if main_str from position offset is less than str, > 0 if it is greater than str, and 0 if they are equal. If length is equal or greater than length of main_str and length is set, substr_compare() prints warning and returns FALSE.

If case_insensitivity is TRUE, comparison is case insensitive.

String functions

substr_replace

mixed substr_replace ( mixed $string, string $replacement, int $start [, int $length] )

Replace text within a portion of a string

substr_count

int substr_count ( string $haystack, string $needle [, int $offset [, int $length]] )

substr_count() returns the number of times the needle substring occurs in the haystack string. Please note that needle is case sensitive.

String functions.

strtolower(),strtoupper()

Converts the case to lower and upper respectively.

strcmp($string1,$string2)

Returns 0 if both are equal

Returns positive int if first string has higher ASCII value.

Returns negative int if second string has higher ASCII value.

similar_text (string $first,string $second

Calculate the similarity between two strings

It returns the number matching characters in both string

String functions

printf($format,$var1.$var2...);

The $format argument returns how the subsequent arguments are printed.

$array = sscanf($string,$format);

The returned array contains each extracted value from the string according to the specified format.

$found = strpbrk($string,$characters)

The string is scanned for any of the characters.if match is found it returns a string starting from the character it just matched to end of the string.

String functions.

$res= strpos($bigstring,$search)

The function returns the position of the $search string in $bigstring

rtrim(),ltrim(),str_ireplace(),strcasecmp(), strnatcmp(),strnatcasecmp(),stripos(), strrpos().Chop is alias of rtrim

string chr ( int $ascii )

Returns a one-character string containing the character specified by ascii

String functions

strrev

Reverse a string

chunk_split Split a string into smaller chunks

string chunk_split ( string $body [, int $chunklen [, string $end]] )

string convert_cyr_string ( string $str, string $from, string $to )

String functions

strstr

Find first occurrence of a string

string strstr ( string $haystack, string $needle )

Returns part of haystack string from the first occurrence of needle to the end of haystack.

If needle is not found, returns FALSE.

If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

Stristr() - case insensitive

Strchr

Alias of strstr()

String functions

Strtok()

string strtok ( string $str, string $token )

strtok() splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token.

Strtr()

string strtr ( string $str, string $from, string $to )

This function returns a copy of str, translating all occurrences of each character in from to the corresponding character in to.

String functions

strcspn

int strcspn ( string $str1, string $str2 [, int $start [, int $length]] )

Find length of initial segment not matching mask

Returns the length of the initial segment of str1 which does not contain any of the characters in str2.

Strcoll

Locale based string comparison

If the current locale is C or POSIX, this function is equivalent to strcmp().

Note that this comparison is case sensitive, and unlike strcmp() this function is not binary safe.

String functions

convert_uuencode(),convert_uudecode().

Levenshtein ()

Calculate Levenshtein distance between two strings or -1, if one of the argument strings is longer than the limit of 255 characters.

str_rot13

Perform the rot13 transform on a string

The ROT13 encoding simply shifts every letter by 13 places in the alphabet while leaving non-alpha characters untouched.

String functions

string addslashes ( string $str )

Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).

addcslashes(),stripcslashes(), stripslashes().

str_shuffle

Randomly shuffles a string

str_split

Convert a string to an array

String functions

string htmlentities ( string $string [, int $quote_style [, string $charset]] )

Convert all applicable characters to HTML entities

ENT_COMPATWill convert double-quotes and leave single-quotes alone.

ENT_QUOTESWill convert both double and single quotes.

ENT_NOQUOTESWill leave both double and single quotes unconverted.

charset-ISO-8859-1,ISO-8859-15,UTF-8.

String functions

Htmlspecialchars()

Convert special characters to HTML entities.

This function returns a string with some of these conversions made

'&' (ampersand) becomes '&'

'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.

''' (single quote) becomes ''' only when ENT_QUOTES is set.

'' (greater than) becomes '>'

String functions

htmlspecialchars_decode

Convert special HTML entities back to characters

string htmlspecialchars_decode ( string $string [, int $quote_style] )

This function is the opposite of htmlspecialchars(). It converts special HTML entities back to characters.Returns the decoded string.

nl2br

Inserts HTML line breaks before all newlines in a string

Returns string with '
' inserted before all newlines.

strip_tags

Strip HTML and PHP tags from a string

String functions

md5($string)

Calculates the md5 hash of a given string using RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash. The hash is a 32-character hexadecimal number.

md5_file($filename)

md5_file Calculates the md5 hash of a given file.

sha1

Calculate the sha1 hash of a string

String functions

soundex

Calculate the soundex key of a string

Soundex keys have the property that words pronounced similarly produce the same soundex key, and can thus be used to simplify searches in databases where you know the pronunciation but not the spelling.

This soundex function returns a string 4 characters long, starting with a letter.

String functions

Metaphone

Calculate the metaphone key of a string.

Similar to soundex() metaphone creates the same key for similar sounding words.

It's more accurate than soundex() as it knows the basic rules of English pronunciation. The metaphone generated keys are of variable length.

money_format

Formats a number as a currency string

number_format

Format a number with grouped thousands

String functions

ord

Return ASCII value of character

parse_str

Parses the string into variables

quoted_printable_decode

Convert a quoted-printable string to an 8 bit string

String functions

quotemeta

Quote meta characters

string quotemeta ( string $str )

Returns a version of str with a backslash character (\) before every character that is among these:

. \ + * ? [ ^ ] ( $ )

Note: This function is binary-safe.

String functions

print

Output a string

int print ( string $arg )

Outputs arg. Returns 1, always.

print() is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.

sprintf

Return a formatted string

str_getcsv

Parse a CSV string into an array.

String functions

wordwrap

Wraps a string to a given number of characters using a string break character

string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] )

Returns a string with str wrapped at the column number specified by the optional width parameter. The line is broken using the (optional) break parameter.

wordwrap() will automatically wrap at column 75 and break using '\n' (newline) if width or break are not given.

If the cut is set to 1, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart

String functions

vfprintf

Write a formatted string to a stream

vprintf

Output a formatted string

vsprintf

Return a formatted string

string vsprintf ( string $format, array $args )

Type specifiers

type specifier that says what type the argument data should be treated as. Possible types:

% - a literal percent character. No argument is required.

b - the argument is treated as an integer, and presented as a binary number.

c - the argument is treated as an integer, and presented as the character with that ASCII value.

d - the argument is treated as an integer, and presented as a (signed) decimal number.

e - the argument is treated as scientific notation (e.g. 1.2e+2).

u - the argument is treated as an integer, and presented as an unsigned decimal number.

f - the argument is treated as a float, and presented as a floating-point number (locale aware).

F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 4.3.10 and PHP 5.0.3.

o - the argument is treated as an integer, and presented as an octal number.

s - the argument is treated as and presented as a string.

x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).

X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).

Numbers

Numbers floating point and decimals

Arithmetic operators

+, -, *, /, %

Operator precedence

Grouping operations inside parentheses, will execute whats inside the parentheses first

Variables

In PHP, variables are denoted by $ followed by the variable's name

Use = to assign value to a variable

Variable names must begin with letter or an underscore

Variable names are case-sensitive

Avoid variable names differ by letter case

Avoid using variable names as function names.

Operating on Variables

Arithmetic and string operators work on variables just as they do on literals

Operator followed by = means apply this operator to the variable

+=, .=, ++, --

Variable interpolation and curly braces

Number functions

$absvalue = abs($number)

If $number is negative the value returned is positive.

$remainder = $dividend % $divisor;

% called modulus operator,returns the remainder.

$result = pow($number,$pow);

PHP does not have power operator. This function must be used instead.

$root = sqrt($number)

Number functions

$ceilinged = ceil($number);

Rounds a fractional number up to next integer.

$floored = floor($number);

Same as ceil but returned value is still a float type

$rounded = round($number);

The function rounds the number to the nearest whole number.

Number functions

$maximum = max ($array);

$minimum = min($array);

$newNumber = base_convert($number,$oldbase,$newbase);

This function converts a number in any base , up to base 36,to a number in any other base,again upto base 36.

$result = rand($min,$max)

Generates random numbers between $min and $max

Number functions

$result = exp($power);

The function returns the natural base 'e' raised to the specified power.

$result = log($number,$base);

This function returns the logarithm of the specified number to the base provided.

Number functions

sin,cos,tan,sinh,cosh,tanh,asin,asinh,acos, acosh,atan,atanh.

Float atan2(float $y,float $x)

This function calculates the arc tangent of the two variables x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result.

The function returns the result in radians, which is between -PI and PI (inclusive).

Number functions

dechex,decoct,decbin.

fmod,hypot.

is_finite, is_infinite,is_nan.

deg2rad,rad2deg,pi.

float lcg_value ( void )

lcg_value() returns a pseudo random number in the range of (0, 1). Combined linear congruential generator.

Number functions

mt_rand()

By default, PHP uses the libc random number generator with the rand() function.The mt_rand() uses a random number generator with known characteristics using the Mersenne Twister, which will produce random numbers four times faster than what the average libc rand() provides.

Chapter Summary

Defining strings in 3 different ways: single quotes, double quotes, and a here document

Escaping: what it is and what characters need to be escaped in each kind of string

Validating a string by checking its length, removing leading and trailing whitespace

Formatting string with printf ()

Chapter Summary

Manipulating the case of string with strtolower (), strtoupper () or ucwords ()

Selecting part of a string with substr ()

Changing part of a string with str_replace ()

Defining numbers in your programs

Doing math with numbers

Storing values in variables

Chapter Summary

Naming variables appropriately

Using combined operators with variables

Using increment and decrement operators with variables

Interpolating variables in strings

CHAPTER 3

Making Decisions and Looping

Making Decisions and Looping

Understanding true and false

Making Decisions

Building Complicated Decisions

Repeating Yourself

Understanding true and false

All expression in PHP program has a truth value: true or false

Most scalar values are true. All integers and floating point (except 0 and 0.0) are true

All strings are true except for two: an empty string and the string containing only 0

An empty array is false

Control statements

Any PHP script is built out of a series of statements.

A statement can be an assignment, a function call, a loop, a conditional statement or even a statement that does nothing (an empty statement).

Statements usually end with a semicolon.

In addition, statements can be grouped into a statement-group by encapsulating a group of statements with curly braces {...}.

A statement-group is a statement by itself as well.

Making Decisions

If () construct runs a block of code if its test expression is true

Add an else to if() statement, to run different statements when the test expression is false

use elseif() with if() to test manyconditions

For a given set of if() and elseif() statements, at most one of the code blocks is run

If statement

it allows for conditional execution of code fragments.

PHP features an if structure that is similar to that of C:

The expression is evaluated to its Boolean value. If expression evaluates to TRUE, PHP will execute statement, and if it evaluates to FALSE - it'll ignore it.

if (expr) statement

If statements

Often you'd want to have more than one statement to be executed conditionally.

In such case there's no need to wrap each statement with an if clause. Instead, you can group several statements into a statement group.

If statements can be nested indefinitely within other if statements, which provides you with complete flexibility for conditional execution of the various parts of your program.

If else statement

Often you'd want to execute a statement if a certain condition is met, and a different statement if the condition is not met. This is what else is for.

else extends an if statement to execute a statement in case the expression in the if statement evaluates to FALSE.

The else statement is only executed if the if expression evaluated to FALSE, and if there were any elseif expressions - only if they evaluated to FALSE this else is executed

else if

elseif, as its name suggests, is a combination of if and else.

It extends an if statement to execute a different statement in case the original if expression evaluates to FALSE.

However, unlike else, it will execute that alternative expression only if the elseif conditional expression evaluates to TRUE.

elseif statement

There may be several elseifs within the same if statement. The first elseif expression (if any) that evaluates to TRUE would be executed.

In PHP, you can also write 'else if' (in two words) and the behavior would be identical to the one of 'elseif' (in a single word). The syntactic meaning is slightly different (if you're familiar with C, this is the same behavior) but the bottom line is that both would result in exactly the same behavior.

The elseif statement is only executed if the preceding if expression and any preceding elseif expressions evaluated to FALSE, and the current elseif expression evaluated to TRUE.

while()

While statements tells PHP to execute the nested statement(s) repeatedly, as long as the while expression evaluates to TRUE.

The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the nested statement(s), execution will not stop until the end of the iteration (each time PHP runs the statements in the loop is one iteration).

Sometimes, if the while expression evaluates to FALSE from the very beginning, the nested statement(s) won't even be run once.

while (expr) statement

do while

do-while loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning.

The main difference from regular while loops is that the first iteration of a do-while loop is guaranteed to run as the truth expression is only checked at the end of the iteration).

whereas it's may not necessarily run with a regular while loop the truth expression is checked at the beginning of each iteration, if it evaluates to FALSE right from the beginning, the loop execution would end immediately.

for statement

A variable can be initialised once unconditionally at the beginning of the loop.

In the beginning of each iteration, test condition is checked. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends.

At the end of each iteration, increment value is evaluated (executed).

for (initialise; test condition; increment value) statement

for ($i = 1; $i 10) { break; } echo $i;}

for loop

Each of the expressions can be empty or contain multiple expressions separated by commas.

Comma separated expressions in test condition are treated similarly to being separated by the || operator but has a lower precedence than ||. expr2 being empty means the loop should be run indefinitely (PHP implicitly considers it as TRUE, like C).

This may not be as useless as you might think, since often you'd want to end the loop using a conditional break statement instead of using the for truth expression.

$i = 1;for (; ; ) { if ($i > 10) { break; } echo $i; $i++;}for ($i = 1, $j = 0; $i $value) statement

foreach

The first form loops over the array given by array_expression. On each loop, the value of the current element is assigned to $value and the internal array pointer is advanced by one (so on the next loop, you'll be looking at the next element).

The second form does the same thing, except that the current element's key will be assigned to the variable $key on each loop.

you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value.

foreach

When foreach first starts executing, the internal array pointer is automatically reset to the first element of the array. This means that you do not need to call reset() before a foreach loop.

Unless the array is referenced, foreach operates on a copy of the specified array and not the array itself.

break

break ends execution of the current for, foreach, while, do-while or switch structure.

break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.

$i = 0; while (++$i) { switch ($i) { case 5: echo "At 5
\n"; break 1; /* Exit only the switch. */ case 10: echo "At 10; quitting
\n"; break 2; /* Exit the switch and the while. */ default: break; }}

continue

continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration.

Note that in PHP the switch statement is considered a looping structure for the purposes of continue.

continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of.

$i = 0;while ($i++ < 5) { echo "Outer
\n"; while (1) { echo "Middle
\n"; while (1) { echo "Inner
\n"; continue 3; }echo "This never gets output.
\n"; } echo "Neither does this.
\n";}

switch

The switch statement is similar to a series of IF statements on the same expression. In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. This is exactly what the switch statement is for.

Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.

switch

The switch statement executes line by line (actually, statement by statement).

In the beginning, no code is executed. Only when a case statement is found with a value that matches the value of the switch expression does PHP begin to execute the statements.

PHP continues to execute the statements until the end of the switch block, or the first time it sees a break statement.

Thus, it is important not to forget break statements to avoid mistakes.

?phpswitch ($i) {case 0: echo "i equals 0";case 1: echo "i equals 1";case 2: echo "i equals 2";}?>

Alternative syntax

PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.

A is equal to 5

return

If called from within a function, the return() statement immediately ends execution of the current function, and returns its argument as the value of the function call.

return() will also end the execution of an eval() statement or script file.

Eval() evaluates the string as PHP code.

return

Note that since return() is a language construct and not a function, the parentheses surrounding its arguments are not required. It is common to leave them out, and you actually should do so as PHP has less work to do in this case.

You should never use parentheses around your return variable when returning by reference, as this will not work. You can only return variables by reference, not the result of a statement. If you use return ($a); then you're not returning a variable, but the result of the expression ($a) (which is, of course, the value of $a).

require()

The require() statement includes and evaluates the specific file.

Require() includes and evaluates a specific file.

include()

The include() statement includes and evaluates the specified file.

The difference between include() and require() The two constructs are identical in every way except how they handle failure.

They both produce a Warning, but require() results in a Fatal Errorand stops execution.

include() does not behave this way, the script will continue regardless.

use require() if you want a missing file to halt processing of the page.

require_once()

This is a behavior similar to the require() statement, with the only difference being that if the code from a file has already been included, it will not be included again.

require_once() should be used in cases where you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.

require_once()

Be aware, that the behaviour of require_once() and include_once() may not be what you expect on a non case sensitive operating system (such as Windows).

include_once()

This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again.

declare

The declare construct is used to set execution directives for a block of code. The syntax of declare is similar to the syntax of other flow control constructs

A tick is an event that occurs for every N low-level statements executed by the parser within the declare block.

The value for N is specified using ticks=N within the declare blocks's directive section.

The event(s) that occur on each tick are specified using the register_tick_function()

declare (directive) statement

ticks

The example profiles the PHP code within the 'declare' block, recording the time at which every second low-level statement in the block was executed.

This information can then be used to find the slow areas within particular segments of code.

This process can be performed using other methods: using ticks is more convenient and easier to implement.

ticks

Building Complicated Decisions

Complicated expressions can be put together with comparison and logical operators

Beware of assignment versus comparison

Beware of floating-point comparison

Strings are compared like dictionary lookup

Beware of strings containing numbers

Use strcmp() to compare like dictionary for strings containing numbers

Repeating Yourself

When a program does something repeatedly, its called looping

Use while(), for(), foreach() for looping

Multiple expression in for() is allowed but only one test expression is possible

Chapter Summary

Evaluating an expression's truth value: true or false

Making a decision with if().

Extending if() with else

Extending if() with elseif()

Putting multiple statements inside an if(), elseif(), or else code block

Chapter Summary

Using the equality (==) and not-equals (!=) operators in test expressions.

Distinguishing between assignment (=) and equality comparison (==)

Using the less-than (), less-than-or-equal-to (=) operators in test expressions

Chapter Summary

Comparing two floating-point numbers with abs()

Comparing two strings with operators

Comparing two strings with strcmp() or strcasecmp()

Using the negation operator (!) in test expressions

Chapter Summary

Using the logical operators (&& and ||) to build more complicated test expressions

Repeating a code block with while ()

Repeating a code block with for ()

CHAPTER 4

WORKING WITH ARRAYS

Working with Arrays

Creating an Array

Creating a Numeric Array

Looping through Arrays

Modifying Arrays

Sorting Arrays

Using Multidimensional Arrays

Array Basics and Creation

An array is made up of elements. Each element has a key and a value. Only one element with a given key can exist.

Any string or number can be the key

An element value can be string, number, true or false; it can also be another array

Creating an Array

Assign a value to a particular array key to create an array

Use array() language construct

With array(), specify a comma-delimited list of key/value pairs

Beware of array and scalar name collision

Creating a Numeric Array

Use array() with only a list of values, instead of key/value pairs

String keyed arrays are associative arrays

PHP automatically uses incrementing numbers for array keys when array creation or add elements with empty brackets syntax

Use count() to find the size of an array

Looping through Arrays

Use foreach() to run a code block once for each element in the array

Changing the loop variables like $key and $value inside foreach() doesn't affect array

Inside foreach(), the elements are accessed in the order they were added to the array

Use for() to access elements in numerical key order

Looping through Arrays

Use array_key_exists(), to check for an element with a certain key

Use in_array(), to check for an element with a particular value

in_array is case-sensitive

Use array_search to find the element key for a given element value

array()

Create an array

array array ( [mixed $...] )

Returns an array of the parameters. The parameters can be given an index with the => operator.

array

Array( [0] => 1 [1] => 1 [2] => 1 [3] => 13 [4] => 1 [8] => 1 [9] => 19)

array()

The above example will output:Array( [1] => January [2] => February [3] => March)

1-based index with array()