SlideShare a Scribd company logo
1 of 47
CN5109
WEB APPLICATION
DEVELOPMENT
Chapter 1
Introduction to Server-Side Development with PHP
What is Server-Side Development?
• The basic hosting of your files is achieved through a web
server.
• Server-side development is much more than web hosting: it
involves the use of a programming technology like PHP or ASP
to create scripts that dynamically generate content.
• Server-side scripting is a method of designing websites so
that the process or user request is run on the originating
server.
• Server-side scripts provide an interface to the user and are
used to limit access to proprietary data and help keep control
of the script source code.
What is Server-Side Development?
Server-Side Scripting Examples
• ActiveVFP
• ASP
• C
• DC
• Java
• JavaScript (using Server-side JavaScript (SSJS) e.g., node.js)
• Perl
• PHP
• Python
• R
• Ruby
Client-side vs. Server-side Scripting
Client-side Environment
• The client-side environment used to run scripts is usually a
browser.
• The processing takes place on the end users computer.
• The source code is transferred from the web server to the
users computer over the internet and run directly in the
browser.
• The scripting language needs to be enabled on the client
computer.
• Sometimes if a user is conscious of security risks they may
switch the scripting facility off.
• When this is the case a message usually pops up to alert the
user when script is attempting to run.
Client-side vs. Server-side Scripting
Server-side Environment
• The server-side environment that runs a scripting language is
a web server.
• A user's request is fulfilled by running a script directly on the
web server to generate dynamic HTML pages.
• This HTML is then sent to the client browser.
• It is usually used to provide interactive web sites that interface
to databases or other data stores on the server.
• This is different from client-side scripting where scripts are run
by the viewing web browser, usually in JavaScript.
• The primary advantage to server-side scripting is the ability to
highly customize the response based on the user's
requirements, access rights, or queries into data stores.
Client-side vs. Server-side Scripting
1. Client page request
2. Decision making
based on requested
page code content
3. HTML
output
returned to
browser
Introduction to PHP
• Created by Rasmus Lerdorf in 1994 and publicly released June
8, 1995
• PHP, which is short for PHP: Hypertext Preprocessor, is a
server-side interpreted scripting language.
• It was designed for creating dynamic web pages and web
pages that effectively work with databases.
• Files that include PHP code on a web server may have any file
extension, but most commonly they end in .PHP, .PHP3, or
.PHTML.
• A PHP file can be created and the contents can be viewed by
using a programming code editing program, such as
Dreamweaver or Notepad++.
Common Use of PHP
• PHP can generate dynamic page content
• PHP can create, open, read, write, delete, and close files on
the server
• PHP can collect form data
• PHP can send and receive cookies
• PHP can add, delete, modify data in your database
• PHP can be used to control user-access
• PHP can encrypt data
Advantages of PHP
• PHP runs on various platforms (Windows, Linux, Unix, Mac OS
X, etc.)
• PHP is compatible with almost all servers used today (Apache,
IIS, etc.)
• PHP supports a wide range of databases
• PHP is free.
• PHP is easy to learn and runs efficiently on the server side
PHP - Environment Setup
• In order to develop and run PHP Web pages three vital
components need to be installed on your computer system.
• Web Server − PHP will work with virtually all Web Server
software, including Microsoft's Internet Information Server
(IIS) but then most often used is freely available Apache
Server.
• Database − PHP will work with virtually all database software,
including Oracle and Sybase but most commonly used is freely
available MySQL database.
• PHP Parser − In order to process PHP script instructions a
parser must be installed to generate HTML output that can be
sent to the Web Browser.
Quiz
1. Define Server Scripting Language
2. Give any four examples of Server Scripting Language
3. Discuss any four common use of PHP.
4. Discuss any four advantages of PHP.
PHP Installation
• To start using PHP, you can:
• Find a web host with PHP and MySQL support
• Install a web server on your own PC, and then install PHP and
MySQL
• If your server has activated support for PHP you do not need
to do anything.
• Just create some .php files, place them in your web directory,
and the server will automatically parse them for you.
• You do not need to compile anything or install any extra tools.
• Because PHP is free, most web hosts offer PHP support.
PHP Installation
• However, if your server does not support PHP, you must:
• install a web server (XAMPP, WAMP)
• install PHP
• install a database, such as MySQL
Write PHP Online
• Write PHP Online is an online code editor which helps you to
write and test run/execute your php code online from your
browser.
• This is one of the simple and powerfull online php code editor
tool available on the internet.
• Write PHP Online supports all PHP functionalities and it runs
using PHP version 7.
http://www.writephponline.com/
Write PHP Online
1. Write the PHP Code.
2. Click the “Run Code” button to see the output.
PHP Syntax
• A PHP script is executed on the server, and the plain HTML
result is sent back to the browser.
• A PHP script can be placed anywhere in the document.
• A PHP script starts with <?php and ends with ?>.
• PHP statements are terminated by a semicolon (;)
• The default file extension for PHP files is ".php".
• A PHP file normally contains HTML tags, and some PHP
scripting code.
PHP Syntax
• Example
<?php
echo "Hello World!";
?>
Output:
PHP in HTML
• PHP is designed to interact with HTML and PHP scripts can be
included in an HTML page without a problem.
• In an HTML page, PHP code is enclosed within special PHP
tags.
<html>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>
HTML in PHP
• To write HTML code in PHP file, you need to use Echo or Print
statement.
<?php
echo “Hello World”;
echo “<h1> Hello World</h1>”;
?>
Output:
Echo/ Print Statement
• Used to output data to the screen.
• The echo statement can be used with or without parentheses:
echo or echo().
<?php
echo "Hello world!";
echo 123;
?>
Output:
Echo / Print Statement
• Using HTML tags in PHP:
<?php
echo “Hello”;
echo “<br>”;
echo “World”;
?>
<?php
echo “Hello <br> World”;
?>
Try This
<?php
echo "<table border=1 width=500>";
echo "<tr>";
echo "<td>1</td><td>2</td>";
echo "</tr>";
echo "<tr>";
echo "<td>3</td><td>4</td>";
echo "</tr>";
echo "</table>";
?>
Output:
Quiz
Write a PHP code to display the following outputs:
a. Welcome to FTMS College
b. University of East London
c. CN5109
Web
Application
Development
Variables
• Variables are "containers" for storing information.
• In PHP, a variable starts with the $ sign, followed by the name
of the variable
Note: When you assign a text value to a variable, put quotes
around the value.
Note: Unlike other programming languages, PHP has no
command for declaring a variable. It is created the moment you
first assign a value to it.
$txt = "Hello world!";
$x = 5;
$y = 10.5;
Variables
Rules for PHP variables:
• A variable starts with the $ sign, followed by the name of the
variable
• A variable name must start with a letter or the underscore
character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric characters
and underscores (A-z, 0-9, and _ )
• Variable names are case-sensitive ($age and $AGE are two
different variables)
Quiz
Determine whether these variable names are valid or not valid.
a. text
b. $txt1
c. $1txt
d. $txt 1
e. $txt#1
f. $txt_1
Comments in PHP
• A comment in PHP code is a line that is not read/executed as
part of the program. Its only purpose is to be read by
someone who is looking at the code.
• Comments can be used to:
• Let others understand what you are doing
• Remind yourself of what you did - Most programmers
have experienced coming back to their own work a
year or two later and having to re-figure out what they
did. Comments can remind you of what you were
thinking when you wrote the code
Comments in PHP
<?php
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
echo “This is not a comment”;
?>
Data Types
• Variables can store data of different types, and different data
types can do different things.
• Data types are declarations for variables. This determines the
type and size of data associated with variables.
• PHP supports the following data types:
• String
• Integer
• Float (floating point numbers - also called double)
• Boolean
• Array
• NULL
Data Types - String
• A string is a sequence of characters, like "Hello world!".
• A string can be any text inside quotes.
<?php
$x = "Hello world!";
$y = “Hi There!”;
echo $x;
echo "<br>";
echo $y;
?>
Data Types - Integer
• An integer data type is a non-decimal number between -
2,147,483,648 and 2,147,483,647.
• Rules for integers:
• An integer must have at least one digit
• An integer must not have a decimal point
• An integer can be either positive or negative
• Integers can be specified in three formats: decimal (10-based),
hexadecimal (16-based - prefixed with 0x) or octal (8-based -
prefixed with 0)
<?php
$x = 5985;
echo $x;
?>
Data Types - Float
• A float (floating point number) is a number with a decimal
point or a number in exponential form.
• In the following example $x is a float.
• The PHP var_dump() function returns the data type and value.
<?php
$x = 10.365;
echo $x;
?>
Data Types - Boolean
• A Boolean represents two possible states: TRUE or FALSE.
• Booleans are often used in conditional testing.
$x = true;
$y = false;
echo $x;
Data Types - Array
• An array stores multiple values in one single variable.
• In the following example $cars is an array.
<?php
$cars = array("Volvo","BMW","Toyota","Honda");
echo $cars[0],"<br>";
echo $cars[1],"<br>";
echo $cars[2],"<br>";
echo $cars[3],"<br>";
?>
Data Types - Null
• Null is a special data type which can have only one value:
NULL.
• A variable of data type NULL is a variable that has no value
assigned to it.
• Tip: If a variable is created without a value, it is automatically
assigned a value of NULL.
• Variables can also be emptied by setting the value to NULL
<?php
$x = null;
echo $x;
?>
Quiz
Identify the data type of the following data:
a. “Cyberjaya”
b. 1.35
c. 50
d. True
e. A
f. “False”
g.
h. 1, 2, 4, 8
i. “25”
Operator
• Operators are used to perform mathematical operations on
variables and values.
• PHP divides the operators in the following groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Increment/Decrement operators
• Logical operators
• String operators
• Array operators
Arithmetic Operators
• Arithmetic operators are used with numeric values to perform
common arithmetical operations, such as addition,
subtraction, multiplication etc.
Operation Name Example Result
+ Addition $x + $y Sum of $x and $y
- Subtraction $x - $y
Difference of $x
and $y
* Multiplication $x * $y
Product of $x
and $y
/ Division $x / $y
Quotient of $x
and $y
% Modulus $x % $y
Remainder of $x
divided by $y
Arithmetic Operators
• Example
$x = 10;
$y = 5;
echo $x + $y,"<br>";
echo $x - $y,"<br>";
echo $x * $y,"<br>";
echo $x / $y,"<br>";
echo $x % $y,"<br>";
Output:
Comparison Operators
• The PHP comparison operators are used to compare two
values (number or string).
Operator Name Example Result
== Equal $x == $y Returns true if $x is equal to $y
!= Not equal $x != $y Returns true if $x is not equal to $y
<> Not equal $x <> $y Returns true if $x is not equal to $y
>
Greater
than
$x > $y Returns true if $x is greater than $y
< Less than $x < $y Returns true if $x is less than $y
>=
Greater
than or
equal to
$x >= $y Returns true if $x is greater than or equal to $y
<=
Less than
or equal to
$x <= $y Returns true if $x is less than or equal to $y
Comparison Operators
• Example
$x = 10;
$y = 5;
echo $x == $y,"<br>";
echo $x <> $y,"<br>";
echo $x < $y,"<br>";
echo $x > $y,"<br>";
Output:
Increment /Decrement Operators
• Increment operators are used to increment a variable's value.
• Decrement operators are used to decrement a variable's
value.
Operator Name Description
++$x Pre-increment
Increments $x by one, then returns
$x
$x++ Post-increment
Returns $x, then increments $x by
one
--$x Pre-decrement
Decrements $x by one, then returns
$x
$x-- Post-decrement
Returns $x, then decrements $x by
one
Increment /Decrement Operators
• Example
$x = 10;
echo $x ,"<br>";
echo ++$x ,"<br>";
echo $x ,"<br>";
echo $x++ ,"<br>";
Output:
Logical Operators
• Example
Operator Name Example Result
and And $x and $y True if both $x and $y are true
or Or $x or $y True if either $x or $y is true
xor Xor $x xor $y
True if either $x or $y is true,
but not both
&& And $x && $y True if both $x and $y are true
|| Or $x || $y True if either $x or $y is true
! Not !$x True if $x is not true
Logical Operators
• Example
$x = 100;
$y = 50;
if ($x == 100 and $y == 50) {
echo "Hello world!";
}
Output:
Quiz
Solve the following equations:
Given $x = 10 and $y = 5
a. $x + $x + $y
b. $x - $y + $x
c. $x + $y * $x
d. $x / $y + $x
e. $x > $y
f. $y != $x
g. ++$x
h. $y--

More Related Content

What's hot (9)

PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
PHP, PHP Developer, Hire PHP Developer, PHP Web Development, Hire PHP Program...
 
Php intro
Php introPhp intro
Php intro
 
Class 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionClass 1 - World Wide Web Introduction
Class 1 - World Wide Web Introduction
 
Php Basics
Php BasicsPhp Basics
Php Basics
 
Introduction to PHP - SDPHP
Introduction to PHP - SDPHPIntroduction to PHP - SDPHP
Introduction to PHP - SDPHP
 
Php intro
Php introPhp intro
Php intro
 
Php
PhpPhp
Php
 
slidesharenew1
slidesharenew1slidesharenew1
slidesharenew1
 

Similar to CN5109 Web Application Development Chapter 1

Similar to CN5109 Web Application Development Chapter 1 (20)

Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
 
Php unit i
Php unit i Php unit i
Php unit i
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
 
web Based Application Devlopment using PHP
web Based Application Devlopment using PHPweb Based Application Devlopment using PHP
web Based Application Devlopment using PHP
 
PHP tutorial | ptutorial
PHP tutorial | ptutorialPHP tutorial | ptutorial
PHP tutorial | ptutorial
 
INTRODUCTION to php.pptx
INTRODUCTION to php.pptxINTRODUCTION to php.pptx
INTRODUCTION to php.pptx
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
Web Technology Fundamentals
Web Technology FundamentalsWeb Technology Fundamentals
Web Technology Fundamentals
 
Welcome to computer programmer 2
Welcome to computer programmer 2Welcome to computer programmer 2
Welcome to computer programmer 2
 
Learn PHP Lacture1
Learn PHP Lacture1Learn PHP Lacture1
Learn PHP Lacture1
 
Web Fundamental
Web FundamentalWeb Fundamental
Web Fundamental
 
Prersentation
PrersentationPrersentation
Prersentation
 

More from Mohd Harris Ahmad Jaal

Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Mohd Harris Ahmad Jaal
 

More from Mohd Harris Ahmad Jaal (20)

Fundamentals of Programming Chapter 7
Fundamentals of Programming Chapter 7Fundamentals of Programming Chapter 7
Fundamentals of Programming Chapter 7
 
Fundamentals of Programming Chapter 6
Fundamentals of Programming Chapter 6Fundamentals of Programming Chapter 6
Fundamentals of Programming Chapter 6
 
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2
 
Fundamentals of Programming Chapter 1
Fundamentals of Programming Chapter 1Fundamentals of Programming Chapter 1
Fundamentals of Programming Chapter 1
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
 
Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8
 
Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7
 
Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
 
Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2
 
Fundamentals of Computing Chapter 10
Fundamentals of Computing Chapter 10Fundamentals of Computing Chapter 10
Fundamentals of Computing Chapter 10
 
Fundamentals of Computing Chapter 9
Fundamentals of Computing Chapter 9Fundamentals of Computing Chapter 9
Fundamentals of Computing Chapter 9
 
Fundamentals of Computing Chapter 8
Fundamentals of Computing Chapter 8Fundamentals of Computing Chapter 8
Fundamentals of Computing Chapter 8
 
Fundamentals of Computing Chapter 7
Fundamentals of Computing Chapter 7Fundamentals of Computing Chapter 7
Fundamentals of Computing Chapter 7
 
Fundamentals of Computing Chapter 6
Fundamentals of Computing Chapter 6Fundamentals of Computing Chapter 6
Fundamentals of Computing Chapter 6
 
Fundamentals of Computing Chapter 5
Fundamentals of Computing Chapter 5Fundamentals of Computing Chapter 5
Fundamentals of Computing Chapter 5
 

Recently uploaded

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

CN5109 Web Application Development Chapter 1

  • 1. CN5109 WEB APPLICATION DEVELOPMENT Chapter 1 Introduction to Server-Side Development with PHP
  • 2. What is Server-Side Development? • The basic hosting of your files is achieved through a web server. • Server-side development is much more than web hosting: it involves the use of a programming technology like PHP or ASP to create scripts that dynamically generate content. • Server-side scripting is a method of designing websites so that the process or user request is run on the originating server. • Server-side scripts provide an interface to the user and are used to limit access to proprietary data and help keep control of the script source code.
  • 3. What is Server-Side Development?
  • 4. Server-Side Scripting Examples • ActiveVFP • ASP • C • DC • Java • JavaScript (using Server-side JavaScript (SSJS) e.g., node.js) • Perl • PHP • Python • R • Ruby
  • 5. Client-side vs. Server-side Scripting Client-side Environment • The client-side environment used to run scripts is usually a browser. • The processing takes place on the end users computer. • The source code is transferred from the web server to the users computer over the internet and run directly in the browser. • The scripting language needs to be enabled on the client computer. • Sometimes if a user is conscious of security risks they may switch the scripting facility off. • When this is the case a message usually pops up to alert the user when script is attempting to run.
  • 6. Client-side vs. Server-side Scripting Server-side Environment • The server-side environment that runs a scripting language is a web server. • A user's request is fulfilled by running a script directly on the web server to generate dynamic HTML pages. • This HTML is then sent to the client browser. • It is usually used to provide interactive web sites that interface to databases or other data stores on the server. • This is different from client-side scripting where scripts are run by the viewing web browser, usually in JavaScript. • The primary advantage to server-side scripting is the ability to highly customize the response based on the user's requirements, access rights, or queries into data stores.
  • 7. Client-side vs. Server-side Scripting 1. Client page request 2. Decision making based on requested page code content 3. HTML output returned to browser
  • 8. Introduction to PHP • Created by Rasmus Lerdorf in 1994 and publicly released June 8, 1995 • PHP, which is short for PHP: Hypertext Preprocessor, is a server-side interpreted scripting language. • It was designed for creating dynamic web pages and web pages that effectively work with databases. • Files that include PHP code on a web server may have any file extension, but most commonly they end in .PHP, .PHP3, or .PHTML. • A PHP file can be created and the contents can be viewed by using a programming code editing program, such as Dreamweaver or Notepad++.
  • 9. Common Use of PHP • PHP can generate dynamic page content • PHP can create, open, read, write, delete, and close files on the server • PHP can collect form data • PHP can send and receive cookies • PHP can add, delete, modify data in your database • PHP can be used to control user-access • PHP can encrypt data
  • 10. Advantages of PHP • PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) • PHP is compatible with almost all servers used today (Apache, IIS, etc.) • PHP supports a wide range of databases • PHP is free. • PHP is easy to learn and runs efficiently on the server side
  • 11. PHP - Environment Setup • In order to develop and run PHP Web pages three vital components need to be installed on your computer system. • Web Server − PHP will work with virtually all Web Server software, including Microsoft's Internet Information Server (IIS) but then most often used is freely available Apache Server. • Database − PHP will work with virtually all database software, including Oracle and Sybase but most commonly used is freely available MySQL database. • PHP Parser − In order to process PHP script instructions a parser must be installed to generate HTML output that can be sent to the Web Browser.
  • 12. Quiz 1. Define Server Scripting Language 2. Give any four examples of Server Scripting Language 3. Discuss any four common use of PHP. 4. Discuss any four advantages of PHP.
  • 13. PHP Installation • To start using PHP, you can: • Find a web host with PHP and MySQL support • Install a web server on your own PC, and then install PHP and MySQL • If your server has activated support for PHP you do not need to do anything. • Just create some .php files, place them in your web directory, and the server will automatically parse them for you. • You do not need to compile anything or install any extra tools. • Because PHP is free, most web hosts offer PHP support.
  • 14. PHP Installation • However, if your server does not support PHP, you must: • install a web server (XAMPP, WAMP) • install PHP • install a database, such as MySQL
  • 15. Write PHP Online • Write PHP Online is an online code editor which helps you to write and test run/execute your php code online from your browser. • This is one of the simple and powerfull online php code editor tool available on the internet. • Write PHP Online supports all PHP functionalities and it runs using PHP version 7. http://www.writephponline.com/
  • 16. Write PHP Online 1. Write the PHP Code. 2. Click the “Run Code” button to see the output.
  • 17. PHP Syntax • A PHP script is executed on the server, and the plain HTML result is sent back to the browser. • A PHP script can be placed anywhere in the document. • A PHP script starts with <?php and ends with ?>. • PHP statements are terminated by a semicolon (;) • The default file extension for PHP files is ".php". • A PHP file normally contains HTML tags, and some PHP scripting code.
  • 18. PHP Syntax • Example <?php echo "Hello World!"; ?> Output:
  • 19. PHP in HTML • PHP is designed to interact with HTML and PHP scripts can be included in an HTML page without a problem. • In an HTML page, PHP code is enclosed within special PHP tags. <html> <body> <?php echo "Hello World!"; ?> </body> </html>
  • 20. HTML in PHP • To write HTML code in PHP file, you need to use Echo or Print statement. <?php echo “Hello World”; echo “<h1> Hello World</h1>”; ?> Output:
  • 21. Echo/ Print Statement • Used to output data to the screen. • The echo statement can be used with or without parentheses: echo or echo(). <?php echo "Hello world!"; echo 123; ?> Output:
  • 22. Echo / Print Statement • Using HTML tags in PHP: <?php echo “Hello”; echo “<br>”; echo “World”; ?> <?php echo “Hello <br> World”; ?>
  • 23. Try This <?php echo "<table border=1 width=500>"; echo "<tr>"; echo "<td>1</td><td>2</td>"; echo "</tr>"; echo "<tr>"; echo "<td>3</td><td>4</td>"; echo "</tr>"; echo "</table>"; ?> Output:
  • 24. Quiz Write a PHP code to display the following outputs: a. Welcome to FTMS College b. University of East London c. CN5109 Web Application Development
  • 25. Variables • Variables are "containers" for storing information. • In PHP, a variable starts with the $ sign, followed by the name of the variable Note: When you assign a text value to a variable, put quotes around the value. Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it. $txt = "Hello world!"; $x = 5; $y = 10.5;
  • 26. Variables Rules for PHP variables: • A variable starts with the $ sign, followed by the name of the variable • A variable name must start with a letter or the underscore character • A variable name cannot start with a number • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) • Variable names are case-sensitive ($age and $AGE are two different variables)
  • 27. Quiz Determine whether these variable names are valid or not valid. a. text b. $txt1 c. $1txt d. $txt 1 e. $txt#1 f. $txt_1
  • 28. Comments in PHP • A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is looking at the code. • Comments can be used to: • Let others understand what you are doing • Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code
  • 29. Comments in PHP <?php // This is a single-line comment # This is also a single-line comment /* This is a multiple-lines comment block that spans over multiple lines */ echo “This is not a comment”; ?>
  • 30. Data Types • Variables can store data of different types, and different data types can do different things. • Data types are declarations for variables. This determines the type and size of data associated with variables. • PHP supports the following data types: • String • Integer • Float (floating point numbers - also called double) • Boolean • Array • NULL
  • 31. Data Types - String • A string is a sequence of characters, like "Hello world!". • A string can be any text inside quotes. <?php $x = "Hello world!"; $y = “Hi There!”; echo $x; echo "<br>"; echo $y; ?>
  • 32. Data Types - Integer • An integer data type is a non-decimal number between - 2,147,483,648 and 2,147,483,647. • Rules for integers: • An integer must have at least one digit • An integer must not have a decimal point • An integer can be either positive or negative • Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0) <?php $x = 5985; echo $x; ?>
  • 33. Data Types - Float • A float (floating point number) is a number with a decimal point or a number in exponential form. • In the following example $x is a float. • The PHP var_dump() function returns the data type and value. <?php $x = 10.365; echo $x; ?>
  • 34. Data Types - Boolean • A Boolean represents two possible states: TRUE or FALSE. • Booleans are often used in conditional testing. $x = true; $y = false; echo $x;
  • 35. Data Types - Array • An array stores multiple values in one single variable. • In the following example $cars is an array. <?php $cars = array("Volvo","BMW","Toyota","Honda"); echo $cars[0],"<br>"; echo $cars[1],"<br>"; echo $cars[2],"<br>"; echo $cars[3],"<br>"; ?>
  • 36. Data Types - Null • Null is a special data type which can have only one value: NULL. • A variable of data type NULL is a variable that has no value assigned to it. • Tip: If a variable is created without a value, it is automatically assigned a value of NULL. • Variables can also be emptied by setting the value to NULL <?php $x = null; echo $x; ?>
  • 37. Quiz Identify the data type of the following data: a. “Cyberjaya” b. 1.35 c. 50 d. True e. A f. “False” g. h. 1, 2, 4, 8 i. “25”
  • 38. Operator • Operators are used to perform mathematical operations on variables and values. • PHP divides the operators in the following groups: • Arithmetic operators • Assignment operators • Comparison operators • Increment/Decrement operators • Logical operators • String operators • Array operators
  • 39. Arithmetic Operators • Arithmetic operators are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc. Operation Name Example Result + Addition $x + $y Sum of $x and $y - Subtraction $x - $y Difference of $x and $y * Multiplication $x * $y Product of $x and $y / Division $x / $y Quotient of $x and $y % Modulus $x % $y Remainder of $x divided by $y
  • 40. Arithmetic Operators • Example $x = 10; $y = 5; echo $x + $y,"<br>"; echo $x - $y,"<br>"; echo $x * $y,"<br>"; echo $x / $y,"<br>"; echo $x % $y,"<br>"; Output:
  • 41. Comparison Operators • The PHP comparison operators are used to compare two values (number or string). Operator Name Example Result == Equal $x == $y Returns true if $x is equal to $y != Not equal $x != $y Returns true if $x is not equal to $y <> Not equal $x <> $y Returns true if $x is not equal to $y > Greater than $x > $y Returns true if $x is greater than $y < Less than $x < $y Returns true if $x is less than $y >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y
  • 42. Comparison Operators • Example $x = 10; $y = 5; echo $x == $y,"<br>"; echo $x <> $y,"<br>"; echo $x < $y,"<br>"; echo $x > $y,"<br>"; Output:
  • 43. Increment /Decrement Operators • Increment operators are used to increment a variable's value. • Decrement operators are used to decrement a variable's value. Operator Name Description ++$x Pre-increment Increments $x by one, then returns $x $x++ Post-increment Returns $x, then increments $x by one --$x Pre-decrement Decrements $x by one, then returns $x $x-- Post-decrement Returns $x, then decrements $x by one
  • 44. Increment /Decrement Operators • Example $x = 10; echo $x ,"<br>"; echo ++$x ,"<br>"; echo $x ,"<br>"; echo $x++ ,"<br>"; Output:
  • 45. Logical Operators • Example Operator Name Example Result and And $x and $y True if both $x and $y are true or Or $x or $y True if either $x or $y is true xor Xor $x xor $y True if either $x or $y is true, but not both && And $x && $y True if both $x and $y are true || Or $x || $y True if either $x or $y is true ! Not !$x True if $x is not true
  • 46. Logical Operators • Example $x = 100; $y = 50; if ($x == 100 and $y == 50) { echo "Hello world!"; } Output:
  • 47. Quiz Solve the following equations: Given $x = 10 and $y = 5 a. $x + $x + $y b. $x - $y + $x c. $x + $y * $x d. $x / $y + $x e. $x > $y f. $y != $x g. ++$x h. $y--