0% found this document useful (0 votes)
56 views21 pages

Web Technology Introduction: Server-Side Script: PHP

This document provides an introduction to server-side web technology and PHP. It discusses server-side scripts, examples of server-side languages including PHP, and key features of PHP such as being open-source, platform independent, and supporting many databases. The document then covers PHP syntax, variables, data types, output functions, control structures, functions, strings, forms, GET vs POST methods, and obtaining data from forms. It also discusses using HTML within PHP code.

Uploaded by

Lân Lu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views21 pages

Web Technology Introduction: Server-Side Script: PHP

This document provides an introduction to server-side web technology and PHP. It discusses server-side scripts, examples of server-side languages including PHP, and key features of PHP such as being open-source, platform independent, and supporting many databases. The document then covers PHP syntax, variables, data types, output functions, control structures, functions, strings, forms, GET vs POST methods, and obtaining data from forms. It also discusses using HTML within PHP code.

Uploaded by

Lân Lu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Web Technology Introduction

Server-side script: PhP


Hieu Dinh Vo

Web Client - Server


1.
2. Execute

3.

Server-side Scripts
Scripts (programs) developed to run
at server side (result will be sent to
clients)
Examples: JSP, ASP, Python, Perl, PhP.
etc

PhP
PHP is an open-source technology
PHP is platform independent
PHP also supports many databases

First PhP Script


(example)

PhP Syntax
Whitespace insensitive
Statements ended by semicolon
Comments
/*.*/ for multiple lines
// or # for a line

PhP Syntax
Variables
All variables in PHP are denoted with a
leading dollar sign ($).
Variables can, but do not need, to be
declared before assignment
Variables used before they are assigned
have default values.

Types
Integers are whole numbers, without a decimal point, like
495.
Doubles are floating-point numbers, like 3.14159 or 49.0.
Booleans have only two possible values: TRUE and FALSE.
NULL is a special type that only has one value: NULL.
Strings are sequences of characters, like PHP 4.0 supports
string operations.
Arrays are named and indexed collections of other values.
Objects are instances of programmer-defined classes,
which can package up both other kinds of values and
functions that are specific to the class.
Resources are special variables that hold references to
resources external to PHP (such as database connections).

Output
echo
print

Control Structures
Similar to JavaScript
if, if else
for
while
switch case

10

Functions
Similar to JavaScript

11

String
$my_string=This is a string;
$another_string=This is another string;
$statement = everything I say;
$question_1 = Do you have to take statement so
literally?\n<BR>;
$question_2 = Do you have to take $statement so
literally?\n<BR>;
echo $question_1;
echo $question_2;
Do you have to take everything I say so literally?
Do you have to take $statement so literally?\n

12

String
$sport = volleyball;
$plan1 = I will play $sport in the
summertime;
$plan2 = I will play {$sport} in the
summertime;

13

String index
$str=abcde
$str[0] a
$str[3] d

14

Concatenation
$my_two_cents = I want to give you a piece of my
mind ;
$third_cent = And another thing;
print($my_two_cents . ... . $third_cent);
I want to give you a piece of my mind ... And another
thing

15

String Functions
$short_string = This string has 29
characters;
strlen($short_string)
strpos($short_string,9)
strrpos($short_string,a)
To compare: ==
strstr($short_string,has)
substr($short_string,5)
substr($short_string,5,6)
16

Forms

orms are means for convey data from users (via Web browse
o server

<body>
<form name="string" action="reverse.php"
method="GET">
Original string: <input type="text"
name="string"/>
<input type="submit" value="Reverse"/>
</form>
</body>

17

POST vs. GET


GET: query data sent as a part of URL
POST: data is hidden

18

Obtaining Data
<?php
$str=$_GET['string'];
$res="";
for($i=0;$i<strlen($str);$i++){
$res=$str[$i].$res;
}
echo $res;
?>

19

HTML & PhP


Two ways to use HTML in PhP
Use echo or print to produce HTML tags
Put HTML tags outside of <?php ?>
segment

20

21

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy