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

LectureSupplement PHP

Chapter 9 discusses server-side scripting languages, which enable dynamic web page generation by executing scripts on a web server. It contrasts static and dynamic websites, highlights the capabilities of server-side scripting such as database access and user customization, and provides examples including PHP and ASP. The chapter also compares PHP and ASP in terms of cost, speed, platform compatibility, base language, and database connectivity.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

LectureSupplement PHP

Chapter 9 discusses server-side scripting languages, which enable dynamic web page generation by executing scripts on a web server. It contrasts static and dynamic websites, highlights the capabilities of server-side scripting such as database access and user customization, and provides examples including PHP and ASP. The chapter also compares PHP and ASP in terms of cost, speed, platform compatibility, base language, and database connectivity.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

MMGD0204

Web Application Technology

Chapter 9
SERVER-SIDE SCRIPTING
LANGUAGE
Chapter 9 – Server-Side Scripting Language

Server-Side Scripting Language

• A web server technology in which a user's request is


fulfilled by running a script directly on the web server
to generate dynamic web pages.
• Used to provide interactive web sites that interface to
databases or other data stores.
• It has ability to highly customize the response based
on the user's requirements, access rights, or queries
into data stores.
Chapter 9 – Server-Side Scripting Language

Static vs. Dynamic Website

• A static website is one that is written in HTML only.


• It has no connection to any database.
• A dynamic website is written using more complex
code and can do a lot more.
• It can read and send data into a database in the
server.
Chapter 9 – Server-Side Scripting Language

What It Can Do?

• Dynamically edit, change, or add any content of a


Web page
• Respond to user queries and form data
• Access databases and return the result to a browser
• Access files and return the result to a browser
• Transform XML data to HTML data and return the
results to a browser
Chapter 9 – Server-Side Scripting Language

What It Can Do?

• Customize a Web page to make it more useful for


individual users
• Provide security and access control to Web pages
• Tailor your output to different types of browsers
• Minimize network traffic
Chapter 9 – Server-Side Scripting Language

How It Works?
Chapter 9 – Server-Side Scripting Language

How It Works?

Dynamic Website
Chapter 9 – Server-Side Scripting Language

Examples of Server-Side Scripting Language

• ASP
• JSP
• PHP
• Python
• CGI
Chapter 9 – Server-Side Scripting Language

PHP

• PHP stands for PHP: Hypertext Preprocessor


• PHP scripts are executed on the server
• PHP supports many databases
• PHP is an open source software: free to download
and use.
• The syntax of PHP is almost similar to C and Java.
• The goal of PHP is to allow web developers to write
dynamically generated pages quickly.
Chapter 9 – Server-Side Scripting Language

PHP Files

• PHP files can contain text, HTML tags and scripts


• PHP files are returned to the browser as plain HTML
• PHP files have a file extension of ".php", ".php3", or
".phtml"
Chapter 9 – Server-Side Scripting Language

PHP Requirements

• PHP Program
• MySQL Database
• Apache Server
Chapter 9 – Server-Side Scripting Language

Basic PHP Syntax

• A PHP scripting block always starts with <?php and


ends with ?>.
• A PHP scripting block can be placed anywhere in the
document.
• There are two basic statements to output text with
PHP: echo and print.
• Each code line in PHP must end with a semicolon.
• The semicolon is a separator and is used to
distinguish one set of instructions from another.
Chapter 9 – Server-Side Scripting Language

Example PHP Syntax

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>
Chapter 9 – Server-Side Scripting Language

ASP

• ASP stands for Active Server Pages.


• ASP is a Microsoft Technology.
• ASP is a program that runs inside IIS (Internet
Information Services).
• It based on visual basic syntax.
• ASP allows us to edit, change or add any content of a
web page.
• It responds to user queries or data given from HTML
forms.
Chapter 9 – Server-Side Scripting Language

ASP File

• An ASP file is just the same as an HTML file


• An ASP file can contain text, HTML, XML, and scripts
• Scripts in an ASP file are executed on the server
• An ASP file has the file extension ".asp"
Chapter 9 – Server-Side Scripting Language

How Does ASP Differ from HTML?

• When a browser requests an HTML file, the server


returns the file
• When a browser requests an ASP file, IIS passes the
request to the ASP engine. The ASP engine reads
the ASP file, line by line, and executes the scripts in
the file. Finally, the ASP file is returned to the
browser as plain HTML
Chapter 9 – Server-Side Scripting Language

What Can ASP Do?

• Dynamically edit, change, or add any content of a


Web page
• Respond to user queries or data submitted from
HTML forms
• Access any data or databases and return the results
to a browser
• Customize a Web page to make it more useful for
individual users
Chapter 9 – Server-Side Scripting Language

What Can ASP Do?

• The advantages of using ASP instead of CGI and


Perl, are those of simplicity and speed
• Provide security - since ASP code cannot be
viewed from the browser
• Clever ASP programming can minimize the
network traffic
Chapter 9 – Server-Side Scripting Language

Basic ASP Syntax

• An ASP file normally contains HTML tags, just like an


HTML file.
• However, an ASP file can also contain server scripts,
surrounded by the delimiters <% and %>.
• Server scripts are executed on the server, and can
contain any expressions, statements, procedures, or
operators valid for the scripting language you prefer
to use.
Chapter 9 – Server-Side Scripting Language

Example ASP Syntax

<html>
<body>

<%
response.write("Hello World!")
%>

</body>
</html>
Chapter 9 – Server-Side Scripting Language

Difference between PHP and ASP

1. Cost

• To run ASP programs one needs IIS installed on a


Windows platform server, which is not free.
• PHP programs run on Linux, which is free.

2. Speed

• PHP code runs faster than ASP.


Chapter 9 – Server-Side Scripting Language

Difference between PHP and ASP

3. Platform Compatibility

• PHP programs can run on various platforms like


Linux, Unix, Windows and Solaris.
• ASP is mainly associated with Windows platforms.

4. Base Language

• PHP is based on C++ language and the syntax.


• ASP is based on Visual Basic syntax.
Chapter 9 – Server-Side Scripting Language

Difference between PHP and ASP

5. Database Connectivity

• PHP, being extremely flexible, can connect to various


databases, the most popular being MySQL.
• ASP mainly uses MS-SQL.

You might also like