Professional Documents
Culture Documents
Part 1
Mike Pavlak
Solutions Consultant
mike.p@zend.com
| 2 Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |
PHP Virtual Lab Part 1
Covering...
• PHP Basics
• HTML Tag Language
• HTML Forms
• PHP Iterative structures
7 million+ developers
2. Facebook.com 7. qq.com
3. Youtube.com 8. Linked In
4. Yahoo.com 9. Taobao.com
HTTP:10080
URL Request *PGM
Server PHP CGI
(FastCGI)
CMD
HTML
Zend Server
DB2 UDB
MySQL
MSSQL Server
| © All rights reserved. Zend Technologies, Inc.
Oracle
Geting Started with PHP on IBM i
12
How PHP works
Nested orientation
|
15
Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |
HTML 4 – Structure of an HTML Document
|
16
Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |
HTML
<?php
<html><head><title>This is my script</title></head><body>
echo ‘Hello World’;
<?php echo ‘Hello World’; ?>
?>
</body></hmtl>
</body></hmtl>
| © All rights reserved. Zend Technologies, Inc.
PHP101
22
Variables
<?php
• Rules
$field1 = 5;
Case senstive $field2 = 10.6;
$field3 = $field1 + $field2;
Begin with $ $field1 = “Hello World”;
• $thisIsMyVariable
?>
• $_AnotherVariable
• $ this is not a variable
Implicit casting
Floating-Point
• 1.7E-308 thru 1.7E+308
• 15 digits of decimal precision
Strings
Boolean
• False is 0, 0.0, false keyword, empty string, object w/no values, null. All
others are true
• Scope
Global – Available everywhere but inside function (sort of)
Associative
Multi-dimensional
$Animals[1] = ‘Cat’
$Animals[2] = ‘Hamster’
• Associative
$Barnyard[‘Cow’] = ‘Calf’
$Barnyard[‘Chicken’] = ‘Chick’
$Barnyard[‘Horse’] = ‘Foal’
• Multi-dimensional
$farm[0] = $Animals
$farm[1] = $Barnyard
| © All rights reserved. Zend Technologies, Inc.
PHP101
26
Strings
• Double quotes
Variables interpolation
|| or
! not
| © All rights reserved. Zend Technologies, Inc.
PHP101
28
Comments
• /* … */ (C Style)
Looks like CL? Pretty close
Comment block,
• Shell style #
| © All rights reserved. Zend Technologies, Inc.
PHP101
29
The dreaded equal sign
• = Single equal sign is assignment
$X=3
$Y=$X
Now $Y = 3
• Else
Condition
if ($x == 5) {
One line, no parenthesis…
$x++;
$y++;
if ($x == 5)
}
$x++;
else {
else
$x--;
$x--;
$y--;
}
|
31
Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |
Flow control (cont…)
• While (condition) {
Do something
• }
• Break and continue
|
33
Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |
Flow control (cont…)
• Foreach
Iterate over elements in an array
$array1[0]=‘ham’;
$array1[1]=‘salami’;
$array1[2]=‘bologna’;
Element 0 is ham
Element 1 is salami
Element 2 is bologna
|
34
Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |
End of Part 1
|
36
Modernizing legacy applications on i5 with PHP © All rights reserved. Zend Technologies, Inc. |