Server Side Scripting PHP Powerpoint Templates Page 1

  • Slides: 18
Download presentation
Server Side Scripting PHP Powerpoint Templates Page 1

Server Side Scripting PHP Powerpoint Templates Page 1

Variable Powerpoint Templates Page 2

Variable Powerpoint Templates Page 2

The Variable Name • start with the “$” characters • Variable names can consist

The Variable Name • start with the “$” characters • Variable names can consist of characters, numbers and underscore “_” • after the “$” character, must be followed or the underscore character "_“ • are case sensitive Example. • $_name • $first_name • $name 3 • $last. Name • global $_name Æ variabel global Powerpoint Templates Page 3

example for using variable <html> <head> <title> Use Variable </title> </head> <body> <? php

example for using variable <html> <head> <title> Use Variable </title> </head> <body> <? php $Name $NAME $name = "Muhammad"; = "Zein"; = "Zidane"; echo "$Name $NAME $name"; ? > </body> </html> Powerpoint Templates Page 4

Indirect Variable References • Variables that are named from the contents of other variables.

Indirect Variable References • Variables that are named from the contents of other variables. • Created when the script is executed (runtime). Example. $name = "Jhon"; $$name = “Registered User"; Result Registered User Powerpoint Templates Page 5

Predefinied Variable • The name of variable has been used by PHP. • Some

Predefinied Variable • The name of variable has been used by PHP. • Some Predefined Variable : Super Global * v $GLOBAL → Refers to all global variables. v $_SERVER → server environment configuration information. v $_GET → The Variable of GET. v $_POST → The Variable of HTTP POST. v $_FILES → The Variable of HTTP File Upload. v $_REQUEST → The Variable of HTTP Request. v $_SESSION → The Variable of Session v $_COOKIE → The Variable of HTTP Cookie. v $php_errormsg → last error message. v $http_response_header → response from the HTTP Header reques * Superglobals: global variables that include a script file, without having to define global $ Powerpoint Templates variable. Page 6

Predefinied Variable Ø $GLOBAL • Referring to the global variables in a script. •

Predefinied Variable Ø $GLOBAL • Referring to the global variables in a script. • Array data type. Powerpoint Templates Page 7

Predefined Variable Ø $_SERVER • Contains the value associated with server information. • Array

Predefined Variable Ø $_SERVER • Contains the value associated with server information. • Array data type. • Complete documentation: http: //www. php. net/manual/en/reserved. var iables. server. php Example : Results : Powerpoint Templates Page 8

Predefined Variable Ø $_GET • Variables from URL parameters. • Array data type. §

Predefined Variable Ø $_GET • Variables from URL parameters. • Array data type. § Example : Create a file with the name predefined_get. php § Access that files in the browser and add the parameter http: //localhost/predefined_get. php? name=Tom Results : Selamat Datang Tom Powerpoint Templates Page 9

Predefined Variable Ø $_POST • Variables derived from the HTTP POST. • Array data

Predefined Variable Ø $_POST • Variables derived from the HTTP POST. • Array data type. • Application in HTML Form § Value Properti “name” input elements, to index arrays $_POST § Example, file : form. php § Example, file : input. php Powerpoint Templates Page 10

Predefined Variable Ø $_FILES • Variables containing items, uploaded via HTTP POST method. •

Predefined Variable Ø $_FILES • Variables containing items, uploaded via HTTP POST method. • 2 -dimensional array of data types • Index Variable $_FILES : § $_FILES[‘foto’][‘name’] → Name of the original file on the client computer. § $_FILES[‘foto’][‘type’] → mime type. Ex : image/gif § $_FILES[‘foto’][‘size’] → file size in byte § $_FILES[‘foto’][‘tmp_name’] → Name of the temporary file that is stored on a server uploaded § $_FILES[‘foto’][‘error’] → Error code that occurred when uploading Powerpoint Templates Page 11

Predefined Variable Ø $_COOKIE • Variables derived from HTTP Cookies. • array data type

Predefined Variable Ø $_COOKIE • Variables derived from HTTP Cookies. • array data type Set cookies on your browser: • setcookie(name, value, expire, path, domain, secure, httponly) • http: //www. php. net/manual/en/function. set cookie. php Powerpoint Templates Page 12

Predefined Variable Ø $_SESSION • Variable deriver from session • Array type data Using

Predefined Variable Ø $_SESSION • Variable deriver from session • Array type data Using Session in PHP • • • session_start() $_SESSION[‘name’] session_unset() session_destroy() http: //www. php. net/manual/en/ref. session. php Powerpoint Templates Page 13

Predefined Variable Ø $_REQUEST • Contains the value of $_GET, $_POST, dan $_COOKIE •

Predefined Variable Ø $_REQUEST • Contains the value of $_GET, $_POST, dan $_COOKIE • array data type Ø $php_errormsg • String Type Data Powerpoint Templates Page 14

Powerpoint Templates Page 15

Powerpoint Templates Page 15

TIPE DATA PHP supported by 8 data type. scalar : • Boolean • Integer

TIPE DATA PHP supported by 8 data type. scalar : • Boolean • Integer • Floating-point • String Compound • Array • Object Khusus • Resources • Null Powerpoint Templates Page 16

Example 1. Boolean <html> <head> <title> Nilai Boolean </title> </head> <body> <h 1> Contoh

Example 1. Boolean <html> <head> <title> Nilai Boolean </title> </head> <body> <h 1> Contoh Nilai Boolean </h 1> <pre> $a = TRUE; $b = FALSE; </pre> Hasil Eksekusi dengan PHP : <? php $a = TRUE; $b = FALSE; echo "$a = $a". " "; echo "$b = $b"; ? > </body> </html> Powerpoint Templates Page 17

2. Integer <html> <head> <title> Integer</title> </head> <Body> <h 1>Integer </h 1> <? php

2. Integer <html> <head> <title> Integer</title> </head> <Body> <h 1>Integer </h 1> <? php $Harga $Jumlah $Harga. Total $Jumlah; = 15000; = 5; = $Harga * echo "Harga = $Harga". " "; echo "Jumlah = $Jumlah". " "; echo "Harga Total = $Harga. Total". " "; $large_number = 2147483647; var_dump ($large_number); echo " "; $large_number = 2147483648; var_dump ($large_number); echo " "; var_dump ( 0 x 80000000 ); echo " "; $million = 1000000; $large_number = 50000 * $million; var_dump ($large_number); ? > </body> </html> Powerpoint Templates Page 18