Chapter 2 Server-Side Scripting Overview
Chapter 2 Server-Side Scripting Overview
Server-Side
Scripting Overview
What are client-Side Scripting
Languages ?
• web browsers executes client side scripting. It is use
when browsers has all code. Source code used to
transfer from web server to user’s computer over
internet and run directly on browsers.
• It allows for more interactivity. It usually performs
several actions without going to user. It cannot be
basically used to connect to databases on web server.
What are Server-Side Scripting
Languages ?
Web servers are used to execute server side scripting.
They are basically used to create dynamic pages. It can
also access the file system residing at web server.
Server-side environment that runs on a scripting
language is a web-server.
Scripts can be written in any of a number of server-side
scripting language available. It is used to retrieve and
generate content for dynamic pages. When you need to
store and retrieve information a database will be used to
contain data. It can use huge resources of server.
Difference b/w client side & server side
scripting :
CLIENT SIDE SCRIPTING SERVER SIDE SCRIPTING
Source code is visible to user. Source code is not visible to user because it’s
output of server side is a HTML page.
It usually depends on browser and it’s In this any server side technology can be use and
version. it does not depend on client.
It runs on user’s computer. It runs on web server.
There are many advantages link with this like The primary advantage is it’s ability to highly
faster. response times, a more interactive customize, response requirements, access rights
application. based on user.
It does not provide security for data. It provides more security for data.
It is a technique use in web development in It is a technique that uses scripts on web server to
which scripts runs on clients browser. produce a response that is customized for each
clients request.
HTML, CSS and javascript are used. PHP, ASP, Python, Java, Ruby are used.
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.
Dynamic Content
</body>
</html>
No matter what’s the current time of the day, if
you request welcome.html, you would always
see Welcome! as the heading. But if you request
welcome.php before 12 noon, you would see the
heading as Good Morning! and Welcome!, if it is
after 12 (date() function uses server’s time and it
may be different from your PC’s time).
Here welcome.html has a static behavior
because it delivers same content always. But
welcome.php has a dynamic behavior
because the content it delivers changes
according to the time of the day. You can
improve this file and have different greetings
for different time periods. As illustrated in this
example, PHP can be used to build dynamic
content that is based on the context. You
would experience the real benefits of PHP’s
dynamic behavior when you create database
driven web applications.
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
What It Can Do? Cont.…..
PHP Program
MySQL Database
Apache Server
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: