Professional Documents
Culture Documents
Web Technology:-
Web technology is the mechanism which enables two or more computing devices to communicate over a
network(internet). Web technologies are the various tools and techniques that are utilized in the process of
communication between different types devices over the internet.
JavaScript:-
JavaScript is a light weight object-oriented programming language, which is used by several websites for scripting
the webpages. It is an interpreted, full-fledged programming language that enables dynamic interactivity on
websites when applied to an HTML document.
JavaScript was first known as LiveScript, but Netscape changed its name to JavaScript, possibly because
of the excitement being generated by Java. JavaScript made its first appearance in .Netscape 2.0 in 1995 with the
name LiveScript.
Features of JavaScript
It is a light-weighted and interpreted language.
It is a case-sensitive language.
All popular browsers support JavaScript as they provide built-in execution environment.
It is a structured programming language. It follows the syntax & structure of C-language.
It is supportable in several OS including Windows, macOS etc.
It provides good control to the users over the web browser.
Class-XII Unit-3 Web Technology-II
Uses of JavaScript
Creating web and Mobile applications
Creating games
Adding interactive behavior to web pages.
To change the appearance of HTML documents.
To display dialog boxes and pop-up windows.
To create the form that respond to user input without accessing the server.
Client-side validation
Advantages of JavaScript
Fast Speed:-JavaScript is executed on the client side that’s why it is very fast.
Easy to learn:- JavaScript is easy to learn. Any one which have basic knowledge of programming can
easily learn JavaScript.
Browser compatible:-JavaScript supports all modern browsers. It can execute on any browser and
produce same result.
Popularity :-JavaScript is very popular web language because it is used every where on the web.
Rich interface:-It provides the drag and drop facilities which can provide the rich look to the web page.
Server load:-JavaScript reduce the server load as it executes on the client side.
Disadvantages of JavaScript
Code Visibility:- JavaScript code is visible to every one and this is the biggest disadvantage of JavaScript.
Stop Render:- One error in JavaScript code can stop whole website to render.
I. Embedding the JavaScript code between a pair of <script> and </script> tag.
II. Creating an external JavaScript file with .js extension and then load it within the page through the src
attribute of the <script> tag.
III. Placing the JavaScript code directly inside an HTML tag using the special tag attributes such as onclick,
onmouseover, onkeypress, onload etc.
Sample Program:
Syntax:
<html>
JavaScript Fundamentals:
Variables
Datatypes
Operators
Functions etc.
Output
a+b=40
a-b=20
a*b=300
a/b=3
a%b=0
++a=32
--b=8
Control Structures
Control structure defines the flow of control within the program. Different control structures used are:
If statement
Class-XII Unit-3 Web Technology-II
If-else statement
If-else if-statement
Switch case
Loops in JavaScript:
There are 3 types of loop in JavaScript:
1. For loop
2. While loop
3. Do-while loop
(a)The syntax of if statement :
if (condition)
{
// the body of if
}
(b)The syntax of if...else statement
if (condition)
{
// block of code if condition is true
}
else
{
// block of code if condition is false
}
(c) Nested if...else Statement
You can also use an if...else statement inside of an if...else statement.
This is known as nested if...else statement.
(a) If statement
// A Program to Check if the number is Positive .
<html>
<body>
<script>
var number;
number= prompt("Enter a number: ");
if (number > 0)
{
document.write("The number is positive<br>");
}
document.write("The if statement is easy");
</script>
<body>
</html>
(b) If-else statement
Example:1
// A Program to check whether the number is even or odd using JavaScript.
<html>
<body>
JavaScript Loops:
The JavaScript loops are used to iterate or repeat the execution of code using for, while and do while loops.
There are 3 types of loops:
1. For loop
2. While loop
3. Do-while loop
Introduction to PHP:-
PHP is a recursive acronym for “PHP: Hypertext Preprocessor”.
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
It can be integrated with a number of popular databases, including MSSQL, Oracle, Sybase, Informix and
Microsoft SQL Server.
PHP syntax is similar to the C programming language.
Advantages of PHP
Open Source and Free of Cost: One of the most vital advantages of PHP is that it is accessible to all.
People can download it from an open-source and get it for free. One can download it anywhere and
readily use it for web application development.
Platform Independence: Another important factor is that since PHP-based applications can run on any
OS such as UNIX, Windows, Linux, etc., people can use it without worrying about a platform where one
can use it.
Characteristics of PHP:
Some important Characteristics of PHP are as follows:
Simplicity
Efficiency
Security
Flexibility
Familiarity etc.
Software requirements :-
To run PHP code, we need the following software on our local computer:
Browser
Web server (e.g. Apache)
PHP (Interpreter)
MSSQL Database (it is optional)
Hardware requirements:-
Desktop/ laptop computer
Windows 2007/2008/2010/2011(32 or 64 bit)
Pentium IV or above processor
RAM 2 GB
Hard disk :160 GB or above
Basic PHP Syntax:
Creating a PHP file is similar to creating an HTML file. In fact, most PHP files are a mixture of PHP code and
HTML. To create a PHP file, simply do the following:
Class-XII Unit-3 Web Technology-II
• Create a new file in your favorite editor.
• Type some PHP code
• Save the file with a .php extension
Example :
<html>
<head>
<title>My first PHP page</title>
</head>
<body>
<?php
echo “Wel come to PHP”;
?>
</body>
</html>
Step 1: To write a code you need a text editor. Some commonly used editors are: Notepad, Notepad ++, Sublime
text, Editplus, Dreamweaver etc.
Step 2: PHP requires a Server to run the code. Some commonly used web servers are : Apache Web server,
Install XAMPP server and connect with MYSQL Database Or Install WAMP server
Variables:
Variables are “containers” for storing information. PHP variables names are case-sensitive. In PHP, a variable
starts with the $ sign, followed by the name of the variables.
Example:
<html>
<body>
<?php
$txt=”Hello world!”;
$x=5;
$y=10.5;
?>
</body>
</html>
Output Variables:
Class-XII Unit-3 Web Technology-II
PHP Echo and Print Statements
The PHP echo and print statement is often used to output a data to the screen. Echo and print are more or less
same. They are both used to output data on the screen.
The difference is small: echo has no return value while print has a return value of 1 so it can be used in
expression. Echo is marginally faster than print.
Raj Kushwaha
Submit
Example3: Write a PHP code to display the factorial of a number given by user.
<html>
<head>
<title>Factorial</title>
</head>
<body>
<b> Factorial Calculation Program</b><br>
<form name=”Dev” method=”POST”>
Input a Number:
<input type=”Number” name=”number”><br>
<input type=”submit” value=”Calculate”>
</form>
<?php
$n=$_POST[‘number’];
$fact=1;
for($i=1;$i<=$n;$i++)
{
$fact=$fact*$i;
}
echo “The factorial of $n=$fact”;
?>
</body>
</html>
Output:-
Factorial Calculation Program
Input a Number 6
Calculate
The factorial of 6= 720
Calculate SI