HNDIT3022
Web Programming
Week2:- Introduction to server-side scripts
Scripting Language
• A script is a set of programming instructions that is interpreted at
runtime.
• They do not require the compilation step and are rather interpreted.
• A scripting language is a programming language designed for
integrating and communicating with other programming languages.
• The purpose of the scripts is usually to enhance the performance or
perform routine tasks for an application.
Scripting Language Vs Programming
Language
• Programming language
• Has all the features needed to develop complete applications.
• The code has to be compiled before it can be executed
• Scripting language
• Mostly used for routine tasks
• The code is usually executed without compiling
• Is usually embedded into other software environments
Activity 2.1
• Discuss Different Scripting Languages.
• Ex:-
• Active Server Pages (ASP)
• Perl
• PHP (Hypertext Pre-Processor)
• JSP(Java Server Pages)
• JavaScript
• Etc..
• Click here for more details
What is Client-Side Scripting Language?
• Web browsers execute client-side scripting.
• Source code is used to transfer from the web server to the user’s
computer over the internet and run directly on browsers.
• It cannot be basically used to connect to databases on a web server.
• It allows for more interactivity.
• It is also used for validations and functionality for user events.
• For example
• Client-side scripting could check the user’s form for errors before submitting it.
• Example Languages:
• Java script
What is Server-Side Scripting Language
• Server-side scripting is a method of programming for the web that
runs software on the server rather than the browser or installed
plugins to create dynamic web pages.
• Example Languages
• Perl, PHP, JSP, Ruby, ColdFusion, and Python
Server-Side Scripting Languages[2]
• Server-Side Scripting Languages
• Customize a web page and dynamically change its contents.
• Respond to queries from users or from HTML forms.
• Access the database and send the information back to the browser.
PHP
Server Side scripting Language
What is PHP?
• PHP is an acronym for "PHP: Hypertext Preprocessor“.
• PHP is a widely used open-source general-purpose server-side scripting
language.
• PHP scripts can only be interpreted on a server that has PHP installed.
• It is especially suited for web development and can be embedded into HTML.
• PHP is free to download and use
How PHP works?
Setting Up a Development Server
• In order to develop and run PHP Web pages three vital components
need to be installed on your computer system.
• Web Server − The most often used is the freely available Apache Server.
• 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.
• Database(Optional) − The most commonly used is the freely available MySQL
database.
Setting Up a Development Server[2]
• There are several software come in the form of a package that binds
the bundled programs together.
• So that you don’t have to install and set them up separately.
• Example:
• WAMP (Windows, Apache, MySQL, and PHP)
• XAMPP(Cross Platform, Apache, Maria DB/MySQL, PHP, Perl)
• LAMP(Linux, Apache, MySQL, and PHP)
• MAMP (Mac, Apache, MySQL, and PHP)
Activity 2.3
• Set up your own development environment using the suitable
software application discussed above. (WAPM, XAMPP, etc..)
PHP Syntax
• PHP is a case sensitive language, “VAR” is not the same as “var”.
• The PHP tags themselves are not case-sensitive, but it is strongly
recommended that we use lowercase letters.
• Ex:- <?php … ?>
The opening <?php tells the webserver to allow the PHP program to interpret all
the following code up to the ?> tag
• A PHP file that contains PHP tags and ends with the extension “.php”.
• A PHP file can also contain tags such as HTML and client-side scripts
such as JavaScript.
Hello World in PHP
• The program shown below is a basic PHP application that outputs the
words “Hello World!” When viewed in a web browser.
<?php
echo “Hello World”;
?>
PHP Example
Questions ?
Thank You !