Professional Documents
Culture Documents
Server-side Programming
Server vs Client
○ Server :
a software which process request from a client
○ Web Server :
a software which process request via HTTP from client and
returns a web page (Apache, Lighttpd, Nginx, Oracle, etc.)
○ Client :
an interface/software from end-user (Web Browser, mobile
apps, software, games, etc.)
Server-side programming vs
Client-side programming
3
Server-side Programming
4
Server Application
5
Server Application
7
PHP
8
Standard Output
9
Variable identifier
$x = 1;
$y = "Hello World";
$z = true;
10
Variable identifier
$PI = 3.14;
echo "PI is $PI";
//Pi is 3.14
11
Variable identifier
$PI = 3.14;
echo "PI is ".$PI;
12
Array
echo $array1[1];
print_r($array1);
var_dump($array1);
13
Array
14
N-Dimensional Array
$array3 = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9, 10]
];
$array3[] = [11, 12, 13, 14];
echo $array3[1][2];
15
Looping and Switch
16
For Loop
foreach($array1 as $a){
echo $a;
}
17
While do, do while
$i = 0; $i = 0;
while($i < count($array1)){ do{
echo $array1[$i]; echo $array1[$i];
echo "<br>"; echo "<br>";
$i++; $i++;
} }
while($i < count($array1))
18
If then else
19
Function
20
Function
function familyName($fname) {
echo "$fname Refsnes.<br>";
}
familyName("Jani");
familyName("Hege");
familyName("Stale");
familyName("Kai Jim");
familyName("Borge");
Variable Scope
22
Variable Scope
○ Global variable :
□ variable that declared outside a function (scope)
○ Local variable :
□ variable that declared in a function (scope)
○ Superglobals variable :
□ Variable that always exists in all scope
Superglobals
○ $_GET ○ $_FILES
○ $_POST ○ $_ENV
○ $_COOKIE ○ $_SERVER
○ $_SESSION ○ $_REQUEST
24
HTML Forms
25
Form Element
26
Form Element
○ <label> ○ <fieldset>
○ <input> ○ <legend>
○ <select> ○ <datalist>
○ <option> ○ <output>
○ <textarea> ○ <optgroup>
○ <button>
27
Label
28
Input
29