Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

18
Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP

Transcript of Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Page 1: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 1

Powerpoint Templates

Server Side Scripting

PHP

Page 2: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 2

Variable

Page 3: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 3

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• $name3• $lastName• global  $_name  Æ variabel  global

Page 4: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 4

example for using variable

<html><head><title> Use Variable </title></head>

<body><?php

$Name = "Muhammad";$NAME = "Zein";$name = "Zidane";

echo "$Name $NAME $name";?></body></html>

Page 5: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 5

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

Page 6: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 6

Predefinied Variable

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

$GLOBAL → Refers to all global variables. $_SERVER → server environment configuration

information. $_GET → The Variable of GET. $_POST → The Variable of HTTP POST. $_FILES → The Variable of HTTP File Upload. $_REQUEST → The Variable of HTTP Request. $_SESSION → The Variable of Session $_COOKIE → The Variable of HTTP Cookie. $php_errormsg → last error message. $http_response_header → response from the HTTP

Header reques

* Superglobals: global variables that include a script file, without having to define global $ variable.

Super Global *

Page 7: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 7

Predefinied Variable

$GLOBAL

• Referring to the global variables in a script.

• Array data type.

Page 8: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 8

Predefined  Variable $_SERVER

• Contains the value associated with server information.

• Array data type.• Complete documentation: http://

www.php.net/manual/en/reserved.variables.server.php

Example :

Results :

Page 9: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 9

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

Page 10: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 10

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

Page 11: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 11

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’][‘ $_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

Page 12: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 12

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.setcookie.php

Page 13: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 13

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

Page 14: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 14

Predefined  Variable

$_REQUEST• Contains the value of $_GET,  

$_POST,  dan   $_COOKIE• array data type

$php_errormsg• String Type Data

Page 15: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 15

Page 16: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 16

PHP supported by 8 data type.

scalar :• Boolean• Integer• Floating-point• String

Compound• Array• Object

Khusus• Resources• Null

TIPE DATA

Page 17: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 17

Example

1. Boolean

<html>

<head>

<title> Nilai Boolean </title>

</head>

<body>

<h1> Contoh Nilai Boolean </h1>

<pre>

$a = TRUE;

$b = FALSE;

</pre>

Hasil Eksekusi dengan PHP : <br>

<?php$a = TRUE;$b = FALSE;echo "\$a = $a"."<br>";echo "\$b = $b";

?>

</body></html>

Page 18: Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.

Powerpoint TemplatesPage 18

2. Integer

<html><head><title> Integer</title></head>

<Body><h1>Integer </h1><?php

$Harga = 15000;$Jumlah = 5;$HargaTotal = $Harga *

$Jumlah;

echo "Harga = $Harga"."<br>";echo "Jumlah = $Jumlah"."<br>";echo "Harga Total =

$HargaTotal"."<br><br>";

$large_number = 2147483647;var_dump ($large_number);echo "<br>";$large_number = 2147483648;var_dump ($large_number);echo "<br>";var_dump ( 0x80000000 );echo "<br>";$million = 1000000;$large_number = 50000 *

$million;var_dump ($large_number);

?></body></html>