Date post: | 04-Jun-2018 |
Category: |
Documents |
Upload: | dikry-alfiannur-wahyu |
View: | 234 times |
Download: | 0 times |
of 22
8/13/2019 W1 PHP Tutorial
1/22
PHP Tutorial
Chu-Cheng Hsieh
1
8/13/2019 W1 PHP Tutorial
2/22
8/13/2019 W1 PHP Tutorial
3/22
Demo
Project 1A
3
8/13/2019 W1 PHP Tutorial
4/22
Scripting block
4
8/13/2019 W1 PHP Tutorial
5/22
First example
5
8/13/2019 W1 PHP Tutorial
6/22
Variable in PHP
start with a $ sign symbol Loosely Typed Language
does not need to be declared
start with a letter or an underscore "_
alpha-numeric characters and underscores (a-Z, 0-9, and _ ) not contain spaces
6
8/13/2019 W1 PHP Tutorial
7/22
String
$txt="Hello World"; concatenation operator (.)
7
8/13/2019 W1 PHP Tutorial
8/22
Operators
Arithmetic +, -, *, /, %, ++, --
Assignment
=, +=, -=, *=, /=, .=, %=
Comparison ==, !=, >, =,
8/13/2019 W1 PHP Tutorial
9/22
Its time to introuce
Zend Studio http://www.zend.com/en/products/studio/
9
8/13/2019 W1 PHP Tutorial
10/22
A useful resource
http://us2.php.net/manual/en/
10
8/13/2019 W1 PHP Tutorial
11/22
ifelse
if (condition) code to be executed if condition is true;
elseif (condition)
code to be executed if condition is true;
else code to be executed if condition is false;
11
8/13/2019 W1 PHP Tutorial
12/22
example of if~else
12
8/13/2019 W1 PHP Tutorial
13/22
switch
13
8/13/2019 W1 PHP Tutorial
14/22
Arrays
$names = array("Peter","Quagmire","Joe"); $names[0] = "Peter";
$names[1] = "Quagmire";
$names[2] = "Joe";
14
8/13/2019 W1 PHP Tutorial
15/22
Associative Arrays
$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34); $ages['Peter'] = "32";
$ages['Quagmire'] = "30";$ages['Joe'] = "34";
Example
15
8/13/2019 W1 PHP Tutorial
16/22
8/13/2019 W1 PHP Tutorial
17/22
Looping ~ for
for (init; cond; incr)
{ code to be executed; } Example
17
8/13/2019 W1 PHP Tutorial
18/22
functions
8/13/2019 W1 PHP Tutorial
19/22
8/13/2019 W1 PHP Tutorial
20/22
Hint for project 1A
eval
Example:
20
8/13/2019 W1 PHP Tutorial
21/22
Hint for Project 1A preg_match
21
8/13/2019 W1 PHP Tutorial
22/22
matches
If matches is provided, then it is filled with the results ofsearch.
$matches[0] will contain the text that matched the full pattern,
$matches[1] will have the text that matched the first captured
parenthesized subpattern,
and so on.
22