0% found this document useful (0 votes)
24 views

PC2102-Module-1-4 2

Websystem and technologies ppt

Uploaded by

itsmekimkatee
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)
24 views

PC2102-Module-1-4 2

Websystem and technologies ppt

Uploaded by

itsmekimkatee
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/ 146

g ie s

d Te c h o lo
an
ems

Web Systems
e b Sy s t
1 02 W
PC-2

and
Technologies
MODULE 1 PREPARED BY: JOHN WILSON RELOVA

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

1
Fundamentals of
Web Systems
g ie s
d Te c h o lo
an
e b Sy s t
ems Introduction
1 02 W
PC-2

The technologies involved in website


development and maintenance can be an
alphabet soup of acronyms, codenames, and
abbreviations, making it hard to understand
what they are, how they work and how they
interact to develop web page design and
functionality.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
d Te c h o lo
an
e b Sy s t
ems Learning Outcomes
1 02 W
PC-2

At the end of this module, students should be able to:

✓ Identify the web technologies used in developing a


website.
✓ Summarize and explain how a web system works
with web technologies.
✓ Evaluate and Identify the process of basic client and
server architecture.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an Lesson 1
d T
e
02 W
PC-2
1
Fundamentals of Web System

World Wide Web (WWW) is a huge distributed system


with millions of clients and servers for accessing web
pages and linked documents over the internet. Servers
maintain collections of documents that are stored
somewhere in a database while clients provide users
an easy to use interface for presenting and navigating
those documents and web pages.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an Lesson 1
d T
e
02 W
PC-2
1
Fundamentals of Web System

A document is fetched from a server by the


user and transferred back to the client when the
connection is made, and presented on the
screen. Now, the web has become more than
just a simple document-based system.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
What is Web Technology?
Web Technology refers to the various tools and
techniques that are utilized in the process of
communication between different types of
devices over the Internet. A web browser is used
to access web pages. Web browsers can be
defined as programs that display text, data,
pictures, animation, and video on the Internet
(Geekforgeeks 2021). hol ogies
c
nd Te a
y s t ems
2 Web S
10
PC-2
g ie s
e c h o lo

b Sy s t
ems Lesson 1.1
an d T
e
02 W
PC-2
1
What is Web Technology?
Web technologies include the following:
✓ Mark-up languages, such as HTML, CSS,
XML(AJAX, JavaScript), CGI, and HTTP (Front-
end or Client-side technologies)
✓ Programming languages and technologies that
help create applications for the web. Some of
these are PHP, Perl, C#, Java, Node.js, Golang
gies
and .NET (Back-end or Server-side technologies)
and T
ec hol o
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies
This is the top web technologies to learn today
(Geekforgeeks 2021).
1. HTML5 - If you know this language, knowing all the
others is a walk in the park. This recent addition to the
HTML family is very equipped and potent in assisting
in web development activities.
2. JavaScript - This programming language lets you
make communication for your website. It was
developed by Netscape and borrows a lot of its syntaxologies
Tech
from the C language. stem
sa n d
Web Sy
C-2 102
P
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies
3. Java - This is the top programming language in the
industry and is currently the perfect language for web
development. Created by Sun Microsystems in the 1990s,
this language is not platform dependent, so using Java and
creating Java-based applications is extremely easy.
4. PHP - This stands for PHP Hypertext Processor. It is one
of the widely-used languages for web development and was
created in 2004. It is an HTML-embedded scripting language
and is useful for creating dynamic web pages. hol ogies
Tec
t ems and
Sy s
02 Web
1
PC-2
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies
5. Python - This is an advanced programming language and
is used for creating websites and mobile apps. It is very
flexible and has a broad range of applications. It can run on
both Linux and Windows-based servers.

6. .NET - This was created by Microsoft in the year 2000.


Though it is used primarily in systems running on Windows,
this language is used in scientific research and academic
fields, thereby more than making up for this feature. hol ogies
Tec
t ems and
Sy s
02 Web
1
PC-2
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies
7. C - This is a standard programming language created in
the 1970s. It is appreciated for its efficiency and is known for
writing system software. It is also used for writing
applications.

8. C++ - This is an intermediary programming language,


initially designed to boost the C language. Created in the
year 1979, it is a very powerful language, and is used in very
important operating systems, such as Windows. logie
s
n d Techo
sa
ystem
2 Web S
10
PC-2
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies
9. C# - This is a multi-paradigm programming language and
is a general-purpose language, used to build up software for
the Microsoft and Windows platforms.

10. SQL - This stands for Structured Query Language and is


a necessary part of web development. Using this language,
web developers can obtain data from large and multifaceted
databases.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies

11. DJANGO - Python-based web framework Django allows


you to create efficient web applications quickly. It is also
called batteries included web framework Django because It
provides built-in features for everything including Django
Admin Interface, default database – SQLlite3, etc.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Top Web Technologies

What we can get from WWW


✓ Read news, listen to music and watch video.
✓ Buy or sell goods online.
✓ Make reservations and orders online
✓ Pay bills and transfer money from one bank to another.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

2
Client Server
Architecture
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 2
e
02 W
PC-2
1
Client Server Architecture
Based in the article “Computer
Basics” by Edu.gcfglobal.org
(2020), client-server architecture
is an architecture of a computer
network in which many clients
(remote processors) request and
receive service from a
centralized server (host
computer).

ol ogies
an d Tech
s
S ystem
02 Web
C-21
g ie s
c h o lo
Sy s t
ems
an d Te
Lesson 2
e b
PC-2
1 02 W
Client Server Architecture
✓ Clients are the web user's internet-connected devices (for
example, your personal computer connected to your wireless
connection or Wi-Fi, or your smartphone connected to your
mobile network like data) and web-accessing software available
on those devices (a web browser like Firefox or Chrome).

✓ Servers are computers that store webpages, sites, or


applications that are accessible over the internet. When a client
device wants to access a webpage, a copy of the webpage is
downloaded from the server using a specific connection onto the es
ologi
client machine to be displayed in the user's web browser. and Tec h
y s t ems
S
02 Web
C-21
d Te c h o lo Lesson 2.1
g ie s
an
ems
02 W
21
e b Sy s t Traditional Web based
PC-This diagram
communication of
shows Systems
the
two computers
using client/server architecture
when sending a request/response
thru Hypertext Transfer Protocol
(HTTP).

The HTTP protocol is a


request/response protocol based
on the client/server-based
architecture where web browsers,
robots, and search engines, etc.
act like HTTP clients, and the Web ol ogies
server acts as a server an d Tech
s
(Edu.gcfglobal.org, 2020). S ystem
02 Web
C-21
d Te c h o loLesson 2.1
g ie s
an
ems
1 02 W
e b Sy s t Traditional Web based
PC-2
Systems
HTTP Request / Response Communication between clients
and servers is done by requests and responses
(Edu.gcfglobal.org, 2020):
1. A client (a browser) sends an HTTP request to the web.
2. A web server receives the request.
3. The server runs an application to process the request.
4. The server returns an HTTP response (output) to the
browser.
5. The client (the browser) receives the response.hologies
an d Tec
s
S ystem
02 Web
C-21
d Te c h o loLesson 2.1
g ie s
an
ems
1 02 W
e b Sy s t Traditional Web based
PC-2
Systems
HTTP Request / Response Communication between clients
and servers is done by requests and responses
(Edu.gcfglobal.org, 2020):
1. A client (a browser) sends an HTTP request to the web.
2. A web server receives the request.
3. The server runs an application to process the request.
4. The server returns an HTTP response (output) to the
browser.
5. The client (the browser) receives the response.hologies
an d Tec
s
S ystem
02 Web
C-21
d Te c h o lo Lesson 2.1
g ie s
an s
stem
Functions
2 1 0 2 We
b S y Traditional Web based
of HTTP
PC-
✓ All communications between Systems
clients and servers is based on
HTTP.
✓ HTTP is a type of simple protocol; a client sends a request to
a server and waits for a response.
✓ HTTP is stateless; it does not have any concept of open
connection and does not require a server to maintain
information of its clients. (HTTP Cookies to store session
information).

A client interacts with web servers through an application called


as Browser. It is responsible for displaying documents on your hol ogies
an d Tec
s
screen. eb S y stem
2W
d Te c h o loLesson 2.1
g ie s
an
ems
1 02 W
e b Sy s t Traditional Web based
PC-2
Systems

hol ogies
ec
and T
yst ems
b S
We
d Te c h o loLesson 2.1
g ie s
an
ems
1 02 W
e b Sy s t Traditional Web based
PC-2
Systems
In addition to HTTP and Client and Server Architecture
(Edu.gcfglobal.org, 2020)
✓ Internet connection - Allows you to send and receive data
on the web.
✓ TCP/IP - Transmission Control Protocol and Internet Protocol
are communication protocols that define how data should travel
across the web.
✓ DNS - Domain Name Servers are like an address book for
websites.
ol ogies
an d Tech
s
S ystem
02 Web
C-21
d Te c h o loLesson 2.1
g ie s
an
ems
1 02 W
e b Sy s t Traditional Web based
PC-2
Systems
✓ Component file - A website is made up of many different
files, which are like the different parts of the goods you buy
from the shop. These files come in two main types:
o Code files - Websites are built primarily from HTML, CSS,
JavaScript, PHP, and MySQL though you'll meet other
technologies a bit later.
o Assets - This is a collective name for all the other stuff that
makes up a website, such as images, music, video, Word
documents, and PDFs. ies
ol og
an d Tech
s
S ystem
02 Web
C-21
g ie s
Te c h o lo
emsLesson 2.2
an d
e b Sy s t
02 W
PC-2
1 Advantages and Disadvantages of
Advantages Client Server Architecture
✓ Improved Data Sharing - Data is retained by usual business
processes and manipulated on a server is available for
designated users (clients) over authorized access.
✓ Integration of Services - Every client is allowed to access
corporate information via the desktop interface eliminating the
necessity to log into a terminal mode or another processor.
✓ Shared Resources amongst Different Platforms -
Applications used for the client/server model are built
regardless of the hardware platform or technical background of ie
the entitled software (Operating System S/W) Tec holog
s and
Sy stem
Web
g ie s
Te c h o lo
ems Lesson 2.2
an d
e b Sy s t
02 W
PC-2
1 Advantages and Disadvantages of
Client Server Architecture
Advantages
✓ Inter-Operation of Data - All development tools used
for client/server applications access the back-end
database server through SQL, an industry standard data
definition and access language, helpful for consistent
management of corporate data.
✓ Data Processing capability despite the location -
We are in an era that undergoes a transformation of
machine-centered systems to user-centered systems. logie
d Techo
t ems an
S y s
Web
g ie s
Te c h o lo
ems
anLesson 2.2
d
e b Sy s t
02 W
PC-2
1 Advantages and Disadvantages of
Client Server Architecture
Advantages
✓ Easy maintenance - Since client/server architecture is
a distributed model representing dispersed responsibilities
among independent computers integrated across a
network, it’s an advantage in terms of maintenance.
✓ Security - Servers have better control access and
resources to ensure that only authorized clients can
access or manipulate data and server-updates are
administered effectively. logie
d Techo
t ems an
S y s
Web
g ie s
Te c h o lo
ems Lesson 2.2
an d
e b Sy s t
02 W
PC-2
1 Advantages and Disadvantages of
Client Server Architecture
Disadvantages
✓ Overloaded servers - When there are
frequent simultaneous client requests, servers
severely get overloaded, forming traffic
congestion.
✓ Impact of centralized architecture - Since its
centralized if a critical server fails, client requests
are not accomplished. ologi
e
d Tech
t ems an
S y s
Web
PC-2
209
Netw
o rking
1

Any
Question?
PC-2
209
Netw
o rking
1
PC-2
209
Netw
o rking
1

THANK YOU
PC-2
209
Netw
o rking
1
g ie s
d Te c h o lo
an
ems
e b Sy s t
1 02 W
PC-2

DOMAIN NAME
SYSTEM (DNS)
MODULE 2
PREPARED BY: JOHN WILSON RELOVA

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

1
Domain Name
System
g ie s
d Te c h o lo
an
e b Sy s t
ems Introduction
1 02 W
PC-2

All computers on the Internet, from your


smartphone or laptop to the servers that serve
content for large websites, locate and
communicate with one another by using
numbers. These numbers are known as IP
addresses.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
d Te c h o lo
an
e b Sy s t
ems Learning Outcomes
1 02 W
PC-2

At the end of this module, students should be able to:

✓ Discuss what is DNS servers and how it works to


web systems
✓ Identify the DNS servers involved when accessing a
webpage
✓ List and discuss, in order, the steps in DNS Lookup

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Domain Name System (DNS)

Based in the article “DNS Servers” by Fisher (2020),


The Domain Name System, commonly known as
“DNS” is the networking system in place that allows us
to resolve human-friendly names to unique
addresses. DNS is the phonebook of the Internet.
Humans access information online through domain
names, like www.google.com or www.facebook.com.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Domain Name System (DNS)
Importance of DNS

If we know a person‘s name but don‘t know their


telephone number, we can simply look it up in a phone
book. DNS provides this same service to the
Internet. When you visit http://www.google.com in a
browser, your computer uses DNS to retrieve the
website‘s IP address of 172.217.24.196.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
Internet Protocol (IP

The Internet Protocol (IP) is a protocol, or set


of rules, for routing and addressing packets
of data so that they can travel across networks
and arrive at the correct destination. Data
traversing the Internet is divided into smaller
pieces, called packets.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
an d Te c h o loLesson 1.2
g ie s
ems
1 02 W
e b Sy s t
Transmission Control
PC-2
Protocol / Internet
Protocol (TCP/IP)
• TCP/IP is a set of standardized rules that
allow computers to communicate on a
network such as the internet.

• TCP/IP is the underlying communication


language of the Internet. ec hol ogies
ms and T
y s te
2 Web S
10
PC-2
an d Te c h o loLesson 1.2
g ie s
ems
1 02 W
e b Sy s t
Transmission Control
PC-2
Protocol / Internet
Protocol (TCP/IP)
As indicated in the name, there are two layers
to TCP/IP (Mitchel, 2020).

✓ Top Layer TCP

✓ Bottom Layer IP ogies


hol
ec
and T
ems
eb Sy s t
-2 102 W
PC
an d Te c h o lo Lesson 1.2
g ie s
s
stem
C- 2 1 0 2 We
b S y
Transmission Control
P
Protocol / Internet
Protocol (TCP/IP)
4 Abstractions Layers embedded in TCP/IP

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.
02 W
PC-2
1
DNS Network

• Fundamentally, the DNS is a database of


website domains and IP addresses. Its key
task is to store the data and link the domain
names and IP addresses when requested.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.
02 W
PC-2
1
DNS Network
However, there are other a couple of other
crucial aspects of DNS that underpin its
functionality (Fisher, 2020):

✓ Distribution
✓ Record Maintenance
✓ Domain Namespace Hierarchy
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.1
02 W
PC-2
1
Domain Namespace

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.1
02 W
PC-2
1
Domain Namespace

To do so, the local DNS server breaks the


domain name into sections. For example,
www.facebook.com would be split into:
✓ com
✓ facebook
✓ www
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Te c h o lo

e b Sy s t
ems Lesson 2.2
an d

02 W
PC-2
1
How DNS Work?
An IP address is given to each device on the
Internet, and that address is necessary to find the
appropriate Internet device - like a street address
is used to find a particular home. When a user
wants to load a webpage, a translation must occur
between what a user types into their web
browser (google.com) and the machine-friendly
address necessary to locate the google.com hol ogies
n d Tec
webpage. eb S y stem
s a

-2 102 W
PC
g ie s
Te c h o lo

e b Sy s t
ems Lesson 2.2
an d

02 W
PC-2
1
How DNS Work?
4 DNS Servers involved in loading a Webpage

1. DNS recursor - The recursor can be thought of


as a librarian who is asked to go find a
particular book somewhere in a library.

2. Root name server - The root server is the first


step in translating (resolving) human readable i
olog
host names into IP addresses. tems and T
ec h
y s
eb S
g ie s
Te c h o lo

e b Sy s t
ems Lesson 2.2
an d

02 W
PC-2
1
How DNS Work?
4 DNS Servers involved in loading a Webpage

3. TLD name server - The top level domain server


(TLD) can be thought of as a specific rack of books
in a library.

4. Authoritative name server - This final name


server can be thought of as a dictionary on a rack
of books, in which a specific name can dbe ec hologi
s an T
translated into its definition. eb S
y s tem
g ie s
an d TeLesson 2.3
c h o lo
ems
Sy s t
PC- 2 1 0 2 We
b
Recursive DNS Server /
Resolver
The recursive resolver is the computer that
responds to a recursive request from a client and
takes the time to track down the DNS record.

ec hologi
and T
y s t ems
eb S
g ie s
Te c h o lo

e b Sy s t
emsLesson 2.4
an d

02 W
PC-2
1
Authoritative DNS Server
Authoritative DNS server is a server that actually
holds, and is responsible for, DNS resource
records.

ec hologi
and T
y s t ems
eb S
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.4
02 W
PC-2
1
Authoritative DNS Server
Difference between Authoritative DNS server &
Recursive DNS Server

ec hologi
and T
y s t ems
eb S
g ie s
Te c h o lo

e b Sy s t Lesson 2.4
ems
an d

02 W
PC-2
1
Authoritative DNS Server
DNS Resolver

The DNS resolver is the first stop in the DNS


lookup, and it is responsible for dealing with the
client that made the initial request. The resolver
starts the sequence of queries that ultimately
leads to a URL being translated into the
necessary IP address.
ec hologi
and T
y s t ems
eb S
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.4
02 W
PC-2
1
Authoritative DNS Server

DNS Resolver

ec hologi
and T
y s t ems
eb S
g ie s
Te c h o lo

e b Sy s t
ems
an d
Lesson 2.4
02 W
PC-2
1
Authoritative DNS Server

3 Types of Queries

✓ Recursive query
✓ Iterative query
✓ Non-recursive query

ec hologi
and T
y s t ems
eb S
g ie s
Te c h o lo

e b Sy s t
ems
an
Lesson 3.
d

02 W
PC-2
1
DNS Lookup
DNS is concerned with a domain name being
translated into the appropriate IP address.

ec hologi
and T
y s t ems
eb S
PC-2
209
Netw
o rking
1

Any
Question?
PC-2
209
Netw
o rking
1
PC-2
209
Netw
o rking
1

THANK YOU
PC-2
209
Netw
o rking
1
g ie s
d Te c h o lo
an
ems

Scripting and
e b Sy s t
1 02 W
PC-2

Server-Side
Programming
MODULE 3 PREPARED BY: JOHN WILSON RELOVA

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

1
Scripting Language
g ie s
d Te c h o lo
an
e b Sy s t
ems Introduction
1 02 W
PC-2
All scripting and server-side languages are
programming languages. The scripting
language is a language where instructions are
written for a run time environment. They do not
require the compilation step and are rather
interpreted. It brings new functions to
applications and glues a complex system
together. c hol ogies
an d Te
s
ystem
2 Web S
10
PC-2
g ie s
d Te c h o lo
an
e b Sy s t
ems Learning Outcomes
1 02 W
PC-2

At the end of this module, students should be able to:

✓ Define what is a scripting language and its


characteristics. ✓ Identify the types of scripting
language and its applications.
✓ Differentiate the structure of a static and dynamic
websites.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Scripting Language

A script is a program that automates the


execution of tasks which could alternatively
be executed one-by-one by a human
operator. It is designed as a glue language. A
scripting language is a programming language
that supports the writing of scripts .
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Scripting Language

Characteristics of Scripting Language

✓ Ease of use
✓ OS facilities
✓ Interpreted from source code

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Scripting Language

Two Types of Scripting Language

1. Server Side - comprises all the scripts that


are executed on the server.

2. Client Side - comprises all the scripts that


are executed on the browser. hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Scripting Language

Two Types of Scripting Language

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1
e
02 W
PC-2
1
Scripting Language
Two Types of Scripting Language

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
Server side VS. Client Side

Server-side scripting languages run on a


web server. When a client sends a request, the
server responds by sending content via HTTP.
In contrast, client-side scripting languages
run on the client end—on their web browser.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
Server side VS. Client Side
The server-side code handles tasks like
validating submitted data and requests,
using databases to store and retrieve data,
and sending the correct data to the client as
required. The benefit of client-side scripts is
that they can reduce demand on the server,
allowing web pages to load faster.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
ems
an d TLesson 1.2
e c h o lo
Sy s t
PC- 2 1 0 Server
2 We
b
Side Scripting Languages and
its applications.
1. PHP - The PHP Hypertext Preprocessor (PHP) is
a programming language that allows web
developers to create dynamic content that
interacts with databases.
2. ASP.NET - is a web development platform,
which provides a programming model, a
comprehensive software infrastructure. ologi
es
n d Tech
sa
ystem
2 Web S
10
PC-2
g ie s
c h o lo
y stem
s an d TLesson 1.2
e
b S
PC- 2 1 0 Server Side Scripting Languages and
2 We

its applications.
. The ASP.NET application codes can be written in
any of the following languages :

✓ C# - is a strongly typed object-oriented


programming language. C# is open source, simple,
modern, flexible, and versatile.
✓ Visual Basic.Net - is an object-oriented l ogies
ho
Tec
programming language. ystem
s an d

2 Web S
10
PC-2
g ie s
c h o lo
y stem
s an d TLesson 1.2
e
b S
PC- 2 1 0 Server Side Scripting Languages and
2 We

its applications.
✓ Jscript - is a script language from Microsoft that
is expressly designed for use within Web pages.

✓ J# - is a programming language that provides


developers with a set of tools for developing Java
applications that can run on Microsoft’s .NET
runtime platform. hol ogies
c
nd Te a
y s t ems
2 Web S
10
PC-2
g ie s
c h o lo
y stem
s an d Te
Lesson 1.2
b S
PC- 2 1 0 Server Side Scripting Languages and
2 We

its applications.
3. Node.js - is a platform built on Chrome's
JavaScript runtime for easily building fast and
scalable network applications.
Features of Node.js
✓ Asynchronous and Event Driven ✓ Very
Fast
✓ Single Threaded but highly scalable ✓ Licenseologies
Tech
✓ No Buffering ystem
san d

2 Web S
10
PC-2
g ie s
c h o lo
y stem
s an d Te
Lesson 1.2
b S
PC- 2 1 0 Server Side Scripting Languages and
2 We

its applications.
4. Python - is one of the most acceptable
languages among web and application developers
because of its strong emphasis on efficiency and
readability.

Python Frameworks
✓ Django gies
hol o
✓ Flask ems
and T
ec

eb Sy s t
-2 102 W
PC
g ie s
c h o lo
y stem
s an d TLesson 1.2
e
b S
PC- 2 1 0 Server Side Scripting Languages and
2 We

its applications.
5. Perl - is a general-purpose programming language
originally developed for text manipulation and now used for
a wide range of tasks including system administration, web
development, and more.

6. Ruby - is a pure object-oriented programming


language. Ruby has features that are similar to those of
Smalltalk, Perl, and Python. Perl, Python, and Smalltalk are
ol ogies
scripting languages. and T
ec h
ems
eb Sy s t
-2 102 W
PC
g ie s
ems
an d TLesson 1.3
e c h o lo
Sy s t
2 1 0 2Client
Web Side Scripting Languages and its
PC-
application
1. HTML - stands for Hypertext Markup Language, and it
is the most widely used language to write Web Pages.

✓ Hypertext refers to the way in which Web pages (HTML


documents) are linked together. Thus, the link available on a
webpage is called Hypertext.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
ems
an d Lesson 1.3
Te c h o lo
Sy s t
2 1 0 2Client
Web Side Scripting Languages and its
PC-
application
2. CSS - Cascading Style Sheets, fondly referred to as CSS,
is a simple design language intended to simplify the
process of making web pages presentable.

✓ CSS handles the look and feel part of a web page.


Using CSS, you can control the color of the text, the style
of fonts, the spacing between paragraphs, how columns
are sized and laid out. c hol ogies
an d Te
s
ystem
2 Web S
10
PC-2
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

2
Server Side
Programming
g ie s
d Te c h o lo
an
e b Sy s t
ems Lesson 2.
1 02 W
PC-2
Server Side Programming

Server-side scripting is a technique used in web


development which involves employing scripts on
a web server which produce a response
customized for each user's request to the website.
The alternative is for the web server itself to
deliver a static web page
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
PC
g ie s -21
c h o lo 02
nd Te We
eb S
ystem
s a
Lesson 2.1 Sy
st e
b
02 W
1 ms
PC-2
Static Websites an
dT
ec h
o lo
The diagram below shows a basic web server gies
architecture for a static site (a static site is one that
returns the same hard-coded content from the
server whenever a particular resource is requested).
g ie s
d Te c h o lo
an
e b Sy s t
ems Lesson 2.2
1 02 W
PC-2
Dynamic Websites

A dynamic website is one where some of the


response content is generated dynamically, only
when needed. On a dynamic website HTML pages
are normally created by inserting data from a
database into placeholders in HTML templates.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
PC
g ie s -21
c h o lo 02
nd Te We
eb S
ystem
s a
Lesson 2.2 b Sy
st e
1 02 W ms
PC-2
Dynamic Websites an
d Tec
h o lo
g ie
s
PC
g ie s -21
c h o lo 02
nd Te We
eb S
ystem
s
Lesson 2.3
a
Sy
st e
b
1 02 W ms
PC-2
Static Website vs. Dynamic Website an
dT
ec h
o lo
g ie
s
g ie s
Lesson 2.4
an d Te c h o lo
ems
Sy s t
102
Web Benefits and Uses of Server-Side
PC-2
Programming

✓ Efficient Storage & Delivery of Information -


Server-side programming allows us to instead store
the information in a database and dynamically
construct and return HTML and other types of files
for rendering by appropriate client-side web
frameworks.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Lesson 2.4
an d Te c h o lo
ems
Sy s t
102
Web Benefits and Uses of Server-Side
PC-2
Programming

✓ Customized User Experience - deeper analysis


of user habits can be used to anticipate their
interests and further customize responses and
notifications, for example providing a list of products
you searched online.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Lesson 2.4
an d Te c h o lo
ems
Sy s t
102
Web Benefits and Uses of Server-Side
PC-2
Programming
✓ Controlled Access Content - Server-side
programming allows sites to restrict access to
authorized users and serve only the information that
a user is permitted to see. For example: Social
networks like Facebook allow users to fully control
their own data but only allow their friends to view or
comment on it. c hol ogies
an d Te
s
ystem
2 Web S
10
PC-2
g ie s
Lesson 2.4
an d Te c h o lo
ems
Sy s t
102
Web Benefits and Uses of Server-Side
PC-2
Programming

✓ Store sessions/states information - Server-side


programming allows developers to make use of
sessions — basically, a mechanism that allows a
server to store information on the current user of a
site and send different responses based on that
information.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
Lesson 2.4
an d Te c h o lo
ems
Sy s t
102
Web Benefits and Uses of Server-Side
PC-2
Programming

✓ Notifications & Communications - Servers can


send general or user-specific notifications through
the website itself or via email, SMS, instant
messaging, video conversations, or other
communications services.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
PC-2
209
Netw
o rking
1

Any
Question?
PC-2
209
Netw
o rking
1
PC-2
209
Netw
o rking
1

THANK YOU
PC-2
209
Netw
o rking
1
g ie s
d Te c h o lo
an
ems
e b Sy s t
1 02 W
PC-2

PHP
Environment
MODULE 4
PREPARED BY: JOHN WILSON RELOVA

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

1
Overview of PHP
g ie s
d Te c h o lo
an
e b Sy s t
ems Introduction
1 02 W
PC-2

PHP is an intuitive, server side scripting


language. Like any other scripting language, it
allows developers to build logic into the
creation of web page content and handle data
returned from a web browser.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
d Te c h o lo
an
e b Sy s t
ems Learning Outcomes
1 02 W
PC-2

At the end of this module, students should be able to:

✓ Define what PHP is, its applications and why they


need to learn this programming language.
✓ Identify how to install XAMPP Control Panel in
different platforms and execute PHP scripts.
✓ Create a webpage using PHP as server-scripting
language.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.
e
02 W
PC-2
1
Overview of PHP

PHP is a popular scripting language used for


creating dynamic web pages and web
applications. The term PHP is an acronym of
Hypertext Preprocessor. It is an open-source,
interpreted, object-oriented server-side
scripting language.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.
e
02 W
PC-2
1
Overview of PHP

PHP started out as a small open source project


that evolved as more and more people found
out how useful it was. Rasmus Lerdorf
unleashed the first version of PHP way back in
1994.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
Why to Learn PHP?
PHP is a MUST for students and working
professionals especially when they are working
in Web Development Domain. I will list down
some of the key advantages of learning PHP :

✓ PHP is a server side scripting language that


is embedded in HTML.
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
emsLesson 1.1
an d T
e
02 W
PC-2
1
Why to Learn PHP?
✓ It is integrated with a number of popular
databases, including MySQL, PostgreSQL,
Oracle, Sybase, Informix, and Microsoft SQL
Server.

✓ PHP is pleasingly zippy in its execution,


especially when compiled as an Apache
gies
module on the Unix side. and T
ec hol o
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
Why to Learn PHP?

✓ PHP supports a large number of major


protocols such as POP3, IMAP, and LDAP...

✓ Object-oriented programming (OOP): PHP


supports OOP concepts like classes, objects,
inheritance, and polymorphism, enabling better
code organization and modularity holog
ies
an d Tec
s
ystem
2 Web S
10
PC-2
g ie s
e c h o lo

b Sy s t
ems Lesson 1.1
an d T
e
02 W
PC-2
1
Why to Learn PHP?
✓ PHP is forgiving: PHP language tries to be
as forgiving as possible.
✓ PHP Syntax is C-Like.
✓ PHP has a large community.
PHP can actually do anything related to server-side
scripting or more popularly known as the backend of a
hol ogies
website. s an d Tec
em
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.1
e
02 W
PC-2
1
Why to Learn PHP?

Characteristics of PHP
Five important characteristics make PHP's
practical nature possible:

✓ Simplicity ✓ Security
✓ Efficiency ✓ Flexibility
✓ Familiarity ec hol ogies
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 1.2
e
02 W
PC-2
1
Applications of PHP
As mentioned before, PHP is one of the most widely
used language over the web. I'm going to list few of
them here (Geekforgeeks 2021):

✓ Server-side web development:


✓ Database-driven applications
✓ Web APIs
✓ E-commerce websites
✓ Using PHP, you can restrict users to access some
ec holo
pages of your website. t ems and T
s
Web Sy
02
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

2
PHP Environment
Setup using XAMPP
an d Te c h o lo Lesson 2.
g ie s
s
stem
- 2 1 0 2 We
b S y
PHP Environment Setup using
P C
XAMPP
In order to develop and run PHP Web pages
three vital components need to be installed on
your computer system

✓ Web Server – In this course, we will use


XAMPP. XAMPP is an easy to install Apache
distribution containing MariaDB, PHP, and Perl.
hol ogies
Just download and start the installer. tems
an d Tec
s
Web Sy
C-2 102
P
an d Te c h o lo Lesson 2.
g ie s
s
stem
- 2 1 0 2 We
b S y
PHP Environment Setup using
P C
✓ Database − PHP XAMPP
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.
This is optional when you download a web server hol ogies
an d Tec
s
like XAMPP. Web
S y stem
C-2 102
P
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 2.1
e
02 W
PC-2
1
What is XAMPP?
XAMPP is an open source cross platform web server,
MySQL database engine, and PHP and Perl package. It is
compiled and maintained by apache.

The acronym XAMPP stands for;


✓ X – Cross platform operating systems meaning it can run
on any OS Mac OX, Windows, and Linux etc.
✓ A – Apache - this is the web server software.
✓ M – MySQL - Database.
hol ogies
✓ P–PHP an d Tec
s tems
✓ P – Perl 2 We
b S y
10
PC-2
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 2.1
e
02 W
PC-2
1
What is XAMPP?
Why use XAMPP?

✓ In order to use PHP, you will need to install PHP,


Apache and may be even MySQL. It’s not easy to install
Apache and configure it.

✓ XAMPP provides an easy to use control panel to


manage Apache, MySQL and other programs such as
Tomcat, FileZilla etc. You don’t have to memorize s
ol ogie
commands for starting apache, MySQL etc. and T
ec h
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 2.3
e
02 W
PC-2
1
XAMPP Configuration
Assuming that you have installed XAMPP on drive C in
Windows using the steps mentioned above. The following
is a list of the basic directories that you are supposed to be
aware of
✓ htdocs - this is the web root directory. All of our
PHP codes will be placed in this directory.
✓ mysql – this directory contains all the information
related to MySQL database engine, by default it runs
on port 3306.
✓ php – this directory contains PHP installation files.
It contains an important file named php.ini. This
directory is used to configure how PHP behaves on
your server.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 2.4
e
02 W
PC-2
1
XAMPP Control Panel
The control panel is used to manage programs installed via XAMPP.
To open the XAMPP control panel (Geekforgeeks 2021).
✓ Click on start menu.
✓ Explore the programs directory and locate Apace Friends then
XAMPP as shown in the diagram below.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 2.4
e
02 W
PC-2
1
XAMPP Control Panel
✓ The diagram below shows the control panel.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

3
PHP Syntax
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 3
e
02 W
PC-2
1
PHP Syntax

I recommend using Sublime Text and Notepad++


as your text editor. A PHP script starts with . When
PHP parses a file, it looks for opening and closing
tags, which are which tell PHP to start and stop
interpreting the code between them.

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems Lesson 3
an d T
e
02 W
PC-2
1
PHP Syntax
The default file extension for PHP files is ".php". A
PHP file normally contains HTML tags, and some
PHP scripting code. Below, we have an example
of a simple PHP file, with a PHP script that uses a
built-in PHP function "echo" to output the text
"Hello World!" on a web page: Create your own
and name it as “sample.php”
hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 3
e
02 W
PC-2
1
PHP Syntax

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an Lesson 3.1
d T
e
02 W
PC-2
1
Running PHP Scripts in XAMPP

The XAMPP suite of Web development tools,


created by Apache Friends, makes it easy to run
PHP (Personal Home Pages) scripts locally on
your computer. Manual installation of a Web
server and PHP requires in-depth configuration
knowledge, but installing XAMPP on Windows
only requires running an installer package. ologi
es
n d Tech
sa
ystem
2 Web S
10
PC-2
g ie s
e c h o lo

b Sy s t
emsLesson 3.2
an d T
e
02 W
PC-2
1
Commenting to PHP
A comment is the portion of a program that exists
only for the human reader and stripped out before
displaying the programs result. There are two
commenting formats in PHP:

✓ Single-line comments − they are generally


used for short explanations or notes relevant to
the local code. Here are the examples of singlelogies
echo
line comments. ystem
san d T

2 Web S
10
PC-2
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 3.2
e
02 W
PC-2
1
Commenting to PHP

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 3.2
e
02 W
PC-2
1
Commenting to PHP

✓ Multi-lines comments − they are generally


used to provide pseudo code algorithms and more
detailed explanations when necessary. The
multiline style of commenting is the same as in C

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 3.2
e
02 W
PC-2
1
Commenting to PHP

hol ogies
ec
and T
ems
eb Sy s t
-2 102 W
PC
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

4
PHP Variable Types
g ie s
e c h o lo

b Sy s t
emsLesson 4
an d T
e
02 W
Here are thePHP
mostVariable
important Types
1
PC-2
things to know about
variables in PHP.
• All variables in PHP are denoted with a leading dollar
sign ($).
• The value of a variable is the value of its most recent
assignment.
• Variables are assigned with the = operator, with the
variable on the left-hand side and the expression to be
evaluated on the right.
• Variables can, but do not need, to be declared before hol ogies
an d Tec
assignment. b S y stem
s
02 We
1
PC-2
g ie s
e c h o lo

b Sy s t
ems Lesson 4
an d T
e
02 W
• Variables PHP Variable Types
1
PC-2
in PHP do not have intrinsic types - a
variable does not know in advance whether it
will be used to store a number or a string of
characters.
• Variables used before they are assigned have
default values.
• PHP does a good job of automatically
converting types from one to another when es
ologi
necessary. ms a
nd Tec h
s te
Web Sy
C-2 102
P
g ie s
e c h o lo

b Sy s t
ems Lesson 4
an d T
e
02 W
PC-2
1
PHP Variable Types
Simple/Scalar Types
• Integers − are whole numbers, without a
decimal point, like 4195.
• Doubles − are floating-point numbers, like
3.14159 or 49.1.
• Booleans − have only two possible values
either true or false.
• Strings − are sequences of characters, like
'PHP supports string operations.'
g ie s
e c h o lo

b Sy s t
Lesson 4
ems
an d T
e
02 W
PC-2
1
PHP Variable Types
Compound Types

• 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.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4
e
02 W
PC-2
1
PHP Variable Types
Special Types

• Resources − are special variables that hold


references to resources external to PHP (such
as database connections).
• NULL − is a special type that only has one
value: NULL.
g ie s
e c h o lo

b Sy s t
emsLesson 4.1
an d T
e
02 W
PC-2
1
PHP Variable Types
They are whole numbers, without a decimal point,
like 4195. They are the simplest type. They
correspond to simple whole numbers, both
positive and negative. Integers can be assigned to
variables, or they can be used in expressions, like
so
g ie s
e c h o lo

b Sy s t
Lesson 4.1
ems
an d T
e
02 W
PC-2
1
PHP Variable Types
Integer can be in decimal (base 10), octal (base
8), and hexadecimal (base 16) format. Decimal
format is the default, octal integers are specified
with a leading 0, and hexadecimals have a
leading 0x.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4.2
e
02 W
PC-2
1
Doubles
They like 3.14159 or 49.1. By default, doubles print with
the minimum number of decimal places needed. For
example, the code:
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4.3
e
02 W
PC-2
1
Booleans
Based in the “PHP Tutorial” by tutorialspoint (n.d), they
have only two possible values either true or false. PHP
provides a couple of constants especially for use as
Booleans: TRUE and FALSE, which can be used like so.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4.3
e
02 W
PC-2
1
Booleans
Each of the following variables has the truth value
embedded in its name when it is used in a Boolean
context.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4.4
e
02 W
PC-2
1
NULL
Based in the “PHP Tutorial” by tutorialspoint (n.d), NULL is a special
type that only has one value: NULL. To give a variable the NULL
value, simply assign it like this.

The special constant NULL is capitalized by convention, but actually it


is case insensitive; you could just as well have typed
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4.5
e
02 W
PC-2
1
Strings
Based in the “PHP Tutorial” by tutorialspoint (n.d), they are
sequences of characters, like "PHP supports string
operations". Following are valid examples of string.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 4.5
e
02 W
PC-2
1
Strings
Singly quoted strings are treated almost literally, whereas doubly
quoted strings replace variables with their values as well as specially
interpreting certain character sequences.
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

5
Variable Scope
PC
g ie s -21
c h o lo 02
nd Te
ystem
s a Lesson 5 We
b Sy
eb S st e
02 W
PC-2
1
Variable Scope ms
an
d Tec
h o lo
g ie
s
The scope of a variable is defined as its extent in
the program within which it can be accessed, i.e.
the scope of a variable is the portion of the
program within which it is visible or can be
accessed.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope

1. Local Variables - The variables declared within


a function are called local variables to that
function and have their scope only in that
particular function. In simple words, it cannot be
accessed outside that function.
PC
g ie s -21
c h o lo 02
nd Te
ystem
s a Lesson 5 We
b Sy
eb S st e
02 W
PC-2
1
Variable Scope ms
an
d Tec
h o lo
g ie
s
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope

2. Function Parameters - Function parameters


are declared after the function name and inside
parentheses. They are declared much like a
typical variable would be:
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope

3. Global Variables - In contrast to local


variables, a global variable can be accessed in
any part of the program. However, in order to be
modified, a global variable must be explicitly
declared to be global in the function in which it is
to be modified.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope

4. Static Variables -It is the characteristic of PHP


to delete the variable, once it completes its
execution and the memory is free. But sometimes
we need to store the variables even after the
completion of function execution.
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 5
e
02 W
PC-2
1
Variable Scope
s PC
l og ie -21
o 02
Tec h We
n d b Sy
m sa st e
st e ms
Sy an
d
Web Tec
0 2 h o lo
C-21 g ie
P s

6
Variable Naming
g ie s
e c h o lo

b Sy s t
ems
an d T
Lesson 6
e
02 W
PC-2
1
Variable Naming
Based in the “PHP Tutorial” by geeksforgeeks (2022), a variable can
have a short name (like x and y) or a more descriptive name (age,
carname, total_volume).

Rules for PHP variables:


• A variable start 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)
PC-2
209
Netw
o rking
1

Any
Question?
PC-2
209
Netw
o rking
1
PC-2
209
Netw
o rking
1

THANK YOU
PC-2
209
Netw
o rking
1

You might also like