Chapter 17: PHP Part I
pages 1 - 19
Irish Software Industry Overview
- Dr. Gerard Lyons
- Head of Department of Information Technology
- 3:00 p.m.
- Board Room, near room 442 in the IT Building
PHP Overview
- PHP web site
- PHP Hypertext Processor or Personal Home Page
- Developed in 1994 by Rasmus Lefdorf
- Open source
- Can interact with a MySQL
database management system
- Server-Side Scripting Language
- Can embed PHP in HTML or vice-versa
- Requires web server software such as Apache Web Server Software,
Microsoft Personal Web Server or Microsoft IIS (Internet
Information Services)
- PHP editors exist
Simple Examples
PHP Basics
- PHP code is embedded between <? and ?>
- PHP statements must be terminated by a semicolon (;)
- Variable names begin with a $, are case sensitive and
have flexible type
Variable Types
- Scalar: integer, double, boolean (TRUE, FALSE), string
- Array
Comments
- Single line: // or #
- Multi-line: /* ... */
Operators
- variable operators: =, +, -, *, /, %
- comparison operators: = =, = = =, !=, <>, <, >, <=, >=
- logical operators: !, &&, ||
Displaying Output
- echo or its shortcut, =
- To print a " in an echo command, use \"
Flow of Control
- if (condition) {} else {}
- switch ($value) { case 1: ... break; ... default: ... break; }
- for (start condition; end condition; value adjustment) { ... }
- do { ... } while (condition);
A More Interesting Example
More Assistance
Monday Exercise
- 5 points. Write a well commented PHP script that runs on esus.
The script should do something interesting and include
both a selection construct and an iterative construct. When
you are finished, place your solution on the memory stick.
- 3 points. Attend Dr. Lyon's talk in the afternoon.