Академический Документы
Профессиональный Документы
Культура Документы
Theory: WAMP is an acronym that traditionally stands for “Window, Apache, MySQL, and
PHP,” which is a common server configuration for a lot of web applications.
WAMP is a variation of LAMP for Windows systems and is often installed as a software bundle
(Apache, MySQL, and PHP). It is often used for web development and internal testing, but may
also be used to serve live websites.
The most important part of the WAMP package is Apache (or "Apache HTTP Server") which is
used run the web server within Windows. By running a local Apache web server on a Windows
machine, a web developer can test webpages in a web browser without publishing them live on
the Internet.
WAMP also includes MySQL and PHP, which are two of the most common technologies used
for creating dynamic websites. MySQL is a high-speed database, while PHP is a scripting
language that can be used to access data from the database. By installing these two components
locally, a developer can build and test a dynamic website before publishing it to a public web
server.
While Apache, MySQL, and PHP are open source components that can be installed
individually, they are usually installed together. One popular package is called "WampServer,"
which provides a user-friendly way to install and configure the "AMP" components on
Windows.
NOTE: The "P" in WAMP can also stand for either Perl or Python, which are other scripting
languages. The Mac version of LAMP is known as MAMP.
after select your file, It‟ll ask following Popup can down load it directly.
Just double click the Wamp Server icon. You‟ll get following small icon in TaskBar.
First it‟s color is Red and change to Orange. At-last it goes to Green color. If green
Now see your WAMP server Home Page with following URL ‘http://localhost/’.
Result:-
Conclusion:-
Industrial Applications :-
WAMP is the popular and industry wide accepted development environment that are been
preferred for open source web application development. These are preferred because of easy
syndication of operating systems, application server, programming language and the database to
develop an open source web application with desirable outcome, that too in optimal
development time.
References:
1. https://en.wikipedia.org/wiki/WampServer
2. https://make.wordpress.org/core/handbook/tutorials/installing-a-local-
server/wampserver/
Questionnaire
Objective: Objective of this module is to provide students an overview of the concepts Web
Technologies, and HTML.
Scope: Create interactive and elegant web pages using HTML 5
HTML
HEAD Tag-This tag contains meta information about HTML page. External files can be
added to web page by importing in HEAD section.
TITLE Tag-This tag is included in HEAD tag .The text between <title> and </title> will
be displayed in title bar of web page.
BODY Tag-The content of web page is included in body tag.
Example 1
<html>
<head>
<title>
Page title This title is displayed on title bar of window
</title>
</head>
<body>
Page body This is actual content of web page
</body >
</html>
Output :
Headings
Headings are defined with the <h1> to <h6> tags.
<h1> defines the largest heading and <h6> defies the smallest heading.
Heading tag has one attribute align which specifies the alignment of the text within a
heading. It has value left, right, center, justify.
Example 2
<html>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
Output
Line breaks
The <br> tag is used when we want to end a line, but don‟t want to start a new paragraph.
The <br> tag forces a line break wherever we place it.
Output
Output
Example 5
<html>
<body>
<p><b>In long quotation the browser inserts white space before and after a blockquote
element. It also insert margins.</b></p>
A long quotation example:
<blockquote>
This is a long quotation. This is a long quotation. This is a long quotation. This is a long
quotation. This is a long quotation.
</blockquote>
<p><b>In short quotation the browser inserts quotation marks around the short quotation
</b></p>
A short quotation example :
<q>This is a short quotation</q>
</body>
</html>
Output
The comments tag is used to insert a comment in HTML code. The web browser ignored
the comment. The comment helps the developer to explain the code and to edit the code.
Syntax- <!--This is a comment-->
Horizontal Rule
Font Tag
The <font> tag specifies the font face, font size, and font colour of text.
Font tag has three attributes size, colour and face.
Size attribute specifies the size of text.
Colour attribute specifies the colour of text.
Face attribute specifies the font of text.
Size attribute specifies the size of text.
Example 7
<html>
<head>
<title>font example</title>
</head>
<body><b>FONT EXAMPLE</b><br><br>
<font size="3" color="red">This is some text in red color!</font><br><br>
<font size="2" face="comic sans ms" color="blue">This is some text in blue
color!</font><br><br>
<font face="verdana" color="green">This is some text in green color!</font>
</body>
</html>
Background
The <body> tag has three attributes bgcolor, background and text which specify the
background of web page.
Bgcolor : The bgcolor attribute specifies the background color. The value of this attribute
can be hexadecimal number, RGB value or name of a color.
Ex. < body bgcolor = “rgb(100,100,100)” >
Background : The background attribute sets an image as the background. The value of
this attribute is the URL of the image which we want to set as background.
<body background=“back.gif”>
Text : The text attribute specifies the color of text.
<body text=“red”>
Example 8
<html>
<head>
<title>body example</title>
</head>
<body background="C:\Documents and Settings\All Users\Documents\My
Pictures\Sample Pictures\Winter.jpg" text="green">
<b>This is example of background tag</b>
</body>
</html>
Output
Web Design Lab (CPL504) 16
HTML links
HTML uses the < a > (anchor) tag to create a link to another document.
An anchor can point to any resource on the web- a HTML page, an image, a sound file, a
movie.
Hyperlink or only link will take us to a new page on clicking the link.
The syntax of creating an anchor- <a href = “url”> Text to be displayed </a>
An anchor tag has following attributes :
o Href attribute : Href is hypertext reference. This attribute specifies the address of
the document which we want to link.
o Name attribute : The name attribute is used to create a link within document which
is called as named anchor. Name anchor is used to create link which directly point to
the specific section in document.
<a name=“label”> some text </a>
o Target attribute : The target attribute specifies location where the linked document
will get opened.
Ex. <a href=“www.google.com” target=“_blank”> Google Web Site </a>
o <noframes> tag : The <noframes> tag is used for browsers that do not handle
frames.
Example 9(a)
<html>
<head>
<title>link example</title>
<body>
<a href=“page2.html”>
This is a link to page 2</a>
Web Design Lab (CPL504) 17
</body>
</html>
Example 9(b)
<html>
<body>
<center>THIS IS PAGE 2...</center>
</body>
Output
Example 10
<html>
<head>
Web Design Lab (CPL504) 18
<title>link example</title>
</head>
<body>
<p>
<a href="#c8">See chapter 8</a></p>
<p> <b> Chapter 1</b> </p>
<p> This is chapter 1</p>
<p> <b> Chapter 2</b> </p>
<p> This is chapter 2</p>
<p> <b> Chapter 3</b> </p>
<p> This is chapter 3</p>
<p> <b> Chapter 4</b> </p>
<p> This is chapter 4</p> <p> <b> Chapter 5</b> </p>
<p> This is chapter 5</p>
<p> <b> Chapter 6</b> </p>
<p> This is chapter 6</p>
<p> <b> Chapter 7</b> </p>
<p> This is chapter 7</p>
<a name="c8"><p><b>Chapter 8</b></p></a>
<p>This is chapter 8</p>
<p><b>Chapter 9</b></p>
<p>This is chapter 9</p>
<p><b>Chapter 10</b></p>
<p>This is chapter 10</p>
<p><b>Chapter 11</b></p>
<p>This is chapter 11</p>
</body>
</html>
Explanation
In this example name attribute is used to create a bookmark inside an HTML document.
HTML Frames
HTML frames allows us to display more than one HTML document in the same browser
window.
Each HTML document is called a frame and each frame is independent of the others.
We can use <frameset> and <frame> tag to create frame.
We must include <frameset> tag instead of <body> tag.
The frameset tag :
The <frameset> tag defines how to divide the window into frames.
The <frameset> tag defines a frameset.
Each frameset defines a set of rows or columns.
Cols-Specifies the number and size of columns in a frameset.
Rows-Specifies the number and size of rows in a frameset.
The values of the rows or columns indicate the amount of screen area each row or
column will occupy.
The frame tag :
The <frame> tag defines what HTML document to put into each frame.
The src attribute specifies the URL of the file which we want to display.
Scrolling attribute control the appearance of the scrollbar within each frame. It can
have three values such as yes, no, auto.
We can resize frames by simply clicking and dragging the frame border. Noresize
attribute avoids this.
Name : Specifies the name of a frame.
Marginheight : Specifies the top and bottom margins of a frame.
Marginwidth : Specifies the left and right margins of a frame.
HTML List
Inside a list item you can put text, line breaks, images, links, other lists, etc.
In HTML, there are 3 types of lists.
Unordered lists
An unordered list is a list of items.
The list items are marked with bullets.
An unordered list starts with the <ul> tag. Each list item starts with te <li> tag.
Ordered lists
In ordered list, the items are marked with numbers.
An ordered list starts with the <ol> tag.
Definition lists
A definition list is not a list of items. This is a list of terms and explanation of the
terms.
Explanation
HTML Forms
HTML forms are used to pass data to a server.
A form is an area that can contain form elements.
Form elements are elements that allow user to enter information like text fields, text area
fields, radio buttons and checkboxes in a form.
The most commonly used input types are :
Text fields : Text fields are used when we want user to type letters, numbers in a
form. This is one-line input field.
Syntax : < input type = “text” name = “fname” >
Password : The characters in a password field are masked.
Syntax : <input type=“password” name=“pwd”>
Radio buttons : Radio buttons are used when we want the user to select one of a
limited number of choices. Only one option can be chose.
Syntax : < input type = “radio” name = “r1” value = “maruti800”> maruti800
Checkboxes : Checkboxes are used when we want the user to select one or more
options of a limited number of choices.
Syntax : <input type = “checkbox” name = “bike”> I like a bike
Text Area Box : Text area allows multiple line of input. It has two attributes rows
and cols. The attribute determine the number of rows and character columns in the
text area field.
Syntax : < texarea rows = 10 cols = 40 name = “t1” >
Example 19
<html>
<body>
<p>Personal InformationForm
<form name=“personal_form” action=“action.asp” method=“get”>
First name: <input type=“text” name=“FirstName” /><br /><br />
Middle name: <input type=“text” name=“FirstName” /><br /><br />
Last name: <input type=“text” name=“LastName” /><br/><br/>
Gender<br><input type="radio" name="gender" value="male" /> Male<br />
<input type="radio" name=" gender" value="female" /> Female<br>
Address
<p><textarea rows="5" cols="28" name="address"></textarea></p>
<p>Education<select name="edu'' size="2">
<option value="Graduate">Graduate</option>
<option value="UnderGraduate">UnderGraduate</option>
<option value="Doctor">Doctor</option>
</select></p>
<br /><br />
<p>
Hobbies<br>
<input type="checkbox" name="c1" value="reading"/>Reading
<input type="checkbox" name="c1" value="writing"/>Writing
<input type="checkbox" name="c1" value="sports"/>Sports
Result:-
Conclusion:-
Industrial Applications:- HTML5 has become the global web standard, used it to benefit
industrial application development. HTML5 A Powerful Tool for Mobile Application
Development
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
1. What is HTML?
2. What are tags?
3. Do all HTML tags have end tag?
4. What is the difference between HTML elements and tags?
5. What is semantic HTML?
6. What is image map?
7. Does a hyperlink only apply to text?
8. What is a marquee?
9. How many tags can be used to separate section of texts?
10. What are empty elements?
Objectives: In this module student will learn, defining a CSS and understanding its purpose
different syntax and types of CSS.
Scope: Design web pages and use CSS to control the layout pages.
Theory:
CSS stands for cascading style sheets.
Styles define how to display HTML elements.
It allows developers to control the style and layout of multiple web pages at a time.
CSS has complete control over the appearance of HTML elements. It can control text
colour, background colours, borders. It allows manipulation and decoration of text.
Syntax
The CSS syntax is made up of three parts :
(i) Selector (ii) Property (iii) Value
Syntax
Selector {property : value ; …}
The selector is normally the HTML tag we want to define.
The property is the attribute we want to change.
Each property can take a value.
Examples
P {text - align : center ; color : green}
h1, h2, h3 {color : red}
The style sheet can be of three types :
External style sheet
All the style properties can be collected and put together in a separate file which has
extension.CSS. This file can be then linked to HTML file so that styles will apply to various
elements. The linking of CSS file and HTML file is done by adding a <link> tag in the <head>
section.
Example 1
First style.html
<html>
<head>
<title> CSS example </title>
<link rel = “stylesheet” type =“text/css” href = “exp1.css” />
</head>
<body>
<h1> This is h1 heading in red color </h1>
Web Design Lab (CPL504) 33
<p> This is first paragraph with blue color </p>
</ body>
</html>
exp1.css
h1 {color : red ;}
p {color : blue ; font-family : sans-serif ;}
In this example rel attribute specifies we are linking a stylesheet and the href attribute
specifies the file containing the style sheet is “expl.css”.
Internal style sheets
The styles can be directly specified in the <head> section. An internal style sheet is used
when a single document has a unique style.
Example 2
<head>
<style>
p {color : red ;}
h1 {color : blue ;}
</ style>
</ head>
<body>
<h1> This is h1 heading in blue color </ h1>
<p> This is first paragraph with red color. This color has been set by using cascading style sheet
</p>
< / body>
< / html>
Inline style sheet :
In this method styles are specified with the tag itself.
Example 3
<p style = “color : cyan ; margin-right : 10 px”>
Result: -
Conclusion: -
Industrial Applications: -
CSS3 style definitions allows for the easy creation of a beautiful and responsive user interface
Web Design Lab (CPL504) 34
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
Questionnaire
1. What is CSS?
2. State advantages of using CSS?
3. Define the components of a CSS style?
4. What is type selector?
5. What is universal selector?
6. Explain class selector?
7. Can you make a class selector particular to an element type?
8. What is attribute selector?
9. How CSS style overriding works>
10. How to select all paragraph elements with a Lang attribute?
Objectives: In this lab student will learn how to define client side scripting and understand its
advantages and disadvantages. Embedding JavaScript code into HTML document using script
tag, and will understand dynamic HTML.
Theory:
What is JavaScript ?
Java script was designed to add interactivity to HTML pages.
A scripting language is a lightweight programming language.
Java script is usually embedded directly into HTML pages.
Java script is an interpreted language i.e. script can be executed without preliminary
compilation.
Functionality provided by JavaScript
JavaScript provide a programming tool to HTML designers : HTML authors are
generally not programmers, but JavaScript is scripting language with a very simple syntax.
JavaScript can put dynamic text into an HTML page : A JavaScript statement like this
: document.write (“<b>“ + name “</b>“) can write a varying text into an HTML page.
JavaScript can react to events : A java script can be set to execute predefined code when
particular event occurs or something happens, for e.g. when a page has finished loading or
when a user clicks on an HTML element.
JavaScript can read and write HTML elements : A Java script can read and change the
content of an HTML element.
JavaScript can be used to validate data : A java script can be used to validate form data
before it is submitted to a server. This saves the server from additional processing.
JavaScript can be used to create cookies : A Java script can be used to store and
retrieve information on the user‟s computer.
How and where to put the JavaScript ?
We have to use <script > tag to insert JavaScript into HTML pages. Inside the <script> tag
we have to use the type attribute to define the scripting language.
The <script type = “text/ javascript”> indicate the start of Java script and </script> tells
where the Java script ends.
Example 1
<html>
<body>
function validate_form ( )
{
valid = true;
if ( document.contact_form.name.value == ““ )
{
alert( “Please fill in the 'Your Name' box.” );
}
if ( document.contact_form.age.value == ““ )
{
alert( “Please fill in the 'Your Age' box.” );
valid = false;
}
if ( document.contact_form.age.value<18 )
{
alert( “You are not eligable for job” );
valid = false;
}
if ( document.contact_form.email.value == ““ )
{
alert( “Please fill in the 'Your Email' box.” );
valid = false;
}
if (( document.contact_form.gender[0].checked == false )
&& ( document.contact_form.gender[1].checked == false ))
{
alert( “Please choose your Gender: Male or Female” );
valid = false;
}
return valid;
}
//-->
</script></head>
<body><b>Registration Form</b>
<form name=“contact_form” method=“post”
action=“form_val.html”
onsubmit=“return validate_form ( );”>
<h1>Please Enter Your Name</h1>
</fom></body></html>
Output
Result:-
Conclusion: -
Industrial Applications: -
Most common uses of java script are Validation, search boxes, animation, unload functions,
date/time, APIs, JSON files and much more. JavaScript allows you to create highly responsive
interfaces that improve the user experience and provide dynamic functionality, without having
to wait for the server to react and show another page.
Web Design Lab (CPL504) 39
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
Questionnaire
1. What is javaScript?
2. Enumerate the difference between java and javaScript?
3. What are javaScript types?
4. What is the use of isNAN function?
5. Between javaScript and an ASP Scipt, which is faster?
6. What is negative infinity?
7. Is it possible to break JavaScript code into several lines?
8. What are undeclared and undefined variables?
9. Write the code for adding new elements dynamically?
10. Define a prompt box?
Objective: Students will be able to how to select, manipulate, animate, and extend a simple
Web page.
Theory :
JQuery, a popular open source JavaScript Library, provides many advanced and cross-browser
functions that can enhance your web applications.
JavaScript is a fairly low-level programming language. It does not provide advanced page
manipulation and decoration functions, and it provides nothing concerning animations.
Moreover, using direct JavaScript can cause issues related to browser incompatibilities. Those
issues have made many JavaScript applications difficult to code, resulting in high maintenance
costs.
JQuery aims to ease all these problems by providing a lightweight library that adds many
advanced and cross-browser functions to the standard language. In addition, there is a very
dynamic community that adds more-advanced components based on JQuery.
A modern Web application wouldn't be complete without some AJAX functionality. JQuery
provides functions for sending HTTP GET and POST requests, and it can work easily with the
JavaScript Object Notation (JSON) format we saw in the first article. This functionality enables
us to query the REST back end we coded in the first article.
JQuery is a JavaScript library, so installing it is just a matter of importing a script inside a Web
page. However, there are a few best practices to be aware of:
JQuery is available through several content delivery networks (CDN). Using those CDNs
instead of installing JQuery on your servers should provide significant performance and
bandwidth gains.
As with any static content, JQuery files should be served compressed. That's why there are two
versions of JQuery available: a minified (or “min”) version, which is small and efficient, and a
development version, which is easier to read and debug. For the rest of this article, we will use
the min version, which is enough for our needs.
JQuery files should be cached on the client side, so you should use the JQuery version number
in the file name.
Now you can include jquery library in your HTML file as follows:
<script type="text/javascript"
src="/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
</script>
</head><body>........</body></html>
Result:-
Conclusion:-
Industrial Applications :-
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
5. http://www.oracle.com/technetwork/java/intro-jquery-166845.html
6. http://jquery.com/
Questionnaire
1.What is jQuery?
2.How JavaScript and jQuery are different?
3. Is jQuery a library for client scripting or server scripting?
4. What is a CDN?
5. What are the Advantages of jQuery?
6. What are selectors in jQuery and how many types of selectors are there?
7. How do you check if an element is empty?
8. What is the use of jquery .each() function?
9. Which is the starting point of code execution in jQuery?
10. Is there any difference between body onload() and document.ready() function?
Objective: This lab gives a basic introduction of to PHP and dynamic programming on the
server side.
Theory:
PHP script can be placed anywhere in the document .A PHP script starts
with <?php and ends with ?>:
<?php
//PHP code goes here
?>
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:
<?php
echo "Hello World!";
?>
Comments in php
A comment in PHP code is a line that is not read/executed as part of the program. Its
only purpose is to be read by someone who is editing the code!
Comments are useful for:
To let others understand what you are doing - Comments let other programmers
understand what you were doing in each step (if you work in a group)
To remind yourself what you did - Most programmers have experienced coming
back to their own work a year or two later and having to re-figure out what they
did. Comments can remind you of what you were thinking when you wrote the
code
PHP supports three ways of commenting:
<?php
// This is a single line comment
# This is also a single line comment
/*
one line
*/
?>
</body>
</html>
In PHP, all user-defined functions, classes, and keywords (e.g. if, else, while, echo,
etc.) are NOT case-sensitive. In the example below, all three echo statements below
are legal (and equal):
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
In the example below, only the first statement will display the value of the $color
variable (this is because $color, $COLOR, and $coLOR are treated as three different
variables):
<?php
$color="red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
>
3. PHP Variable
As with algebra, PHP variables can be used to hold values (x=5) or expressions (z=x
+ y). A variable can have a short name (like x and y) or a more descriptive name
(age, carname, total_volume).
A variable starts 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 ($y and $Y are two different variables)
<?php
$txt="Hello world!";
$x=5;
$y=10.5;
?>
In the example above, notice that we did not have to tell PHP which data type the
variable is.
PHP automatically converts the variable to the correct data type, depending on its
value.
In other languages such as C, C++, and Java, the programmer must declare the
name and type of the variable before using it.
In PHP, variables can be declared anywhere in the script. The scope of a variable is
the part of the script where the variable can be referenced/used. PHP has three
different variable scopes:
local
global
static
A variable declared outside a function has a GLOBAL SCOPE and can only
be accessed outside a function.
A variable declared within a function has a LOCAL SCOPE and can only be
accessed within that function.
The following example tests variables with local and global scope:
<?php
$x=5; // global scope
function myTest() {
$y=10; // local scope
echo "<p>Test variables inside the function:</p>";
echo "Variable x is: $x";
echo "<br>";
echo "Variable y is: $y";
}
myTest();
In PHP there are two basic ways to get output: echo and print.
The Php Echo Statement: echo is a language construct, and can be used with or
without parentheses: echo or echo().
<?php
echo "<h2>PHP is fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This", " string", " was", " made", " with multiple prameters.";
$txt1="Learn PHP";
$txt2="W3Schools.com";
$cars=array("Volvo","BMW","Toyota");
echo $txt1;
echo "<br>";
echo "Study PHP at $txt2";
echo "My car is a {$cars[0]}";
?>
The PHP print Statement : print is also a language construct, and can be used with
or without parentheses: print or print().
<?php
print "<h2>PHP is fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn PHP!";
$txt1="Learn PHP";
$txt2="W3Schools.com";
$cars=array("Volvo","BMW","Toyota");
print $txt1;
print "<br>";
print "Study PHP at $txt2";
Web Design Lab (CPL504) 46
print "My car is a {$cars[0]}";
?>
String
A string is a sequence of characters, like "Hello world!".
A string can be any text inside quotes. You can use single or double quotes:
<?php
$x = "Hello world!";
echo $x;
$x = 'Hello world!';?>
Integers
<?php
$x = 5985;
var_dump($x);
echo "<br>";
$x = -345; // negative number
var_dump($x);
echo "<br>";
$x = 0x8C; // hexadecimal number
var_dump($x);
echo "<br>";
$x = 047; // octal number
var_dump($x);
?>
<?php
$x = 10.365;
Web Design Lab (CPL504) 47
var_dump($x);
echo "<br>";
$x = 2.4e3;
var_dump($x);
echo "<br>";
$x = 8E-5;
var_dump($x);
?>
Booleans
Booleans can be either TRUE or FALSE. Booleans are often used in conditional
testing.
$x=true;
$y=false;
PHP Arrays
An array stores multiple values in one single variable. In the following example
we create an array, and then use the PHP var_dump() function to return the data
type and value of the array:
<?php
$cars=array("Volvo","BMW","Toyota");
var_dump($cars);
?>
A string is a sequence of characters, like "Hello world!" we will look at some commonly
used functions to manipulate strings.
The strlen() function returns the length of a string, in characters. The example below
returns the length of the string "Hello world!":
<?php
echo strlen("Hello world!");
?>
The strpos() function is used to search for a specified character or text within a string. If
a match is found, it will return the character position of the first match. If no match is
found, it will return FALSE.
The example below searches for the text "world" in the string "Hello world!":
Web Design Lab (CPL504) 48
<?php
echo strpos("Hello world!","world");
?>
7. PHP Operators
The PHP comparison operators are used to compare two values (number or string):
8. if...else...elseif Statements
very often when you write code, you want to perform different actions for different
decisions. You can use conditional statements in your code to do this.
if (condition) {
code to be executed if condition is true;
}
if...else statement - executes some code if a condition is true and another code if the
condition is false
if (condition) {
code to be executed if condition is true;
} else {
code to be executed if condition is false;
}
if (condition) {
code to be executed if condition is true;
} elseif (condition) {
code to be executed if condition is true;
} else {
code to be executed if condition is false;
}
Web Design Lab (CPL504) 50
switch statement - selects one of many blocks of code to be executed
switch (n) {
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
case label3:
code to be executed if n=label3;
break;
...
default:
code to be executed if n is different from all labels;
}
9. PHP Loops
Often when you write code, you want the same block of code to run over and over again
in a row. Instead of adding several almost equal code-lines in a script, we can use loops
to perform a task like this.
while - loops through a block of code as long as the specified condition is true
do...while - loops through a block of code once, and then repeats the loop as long
as the specified condition is true
do {
code to be executed;
} while (condition is true);
Besides the built-in PHP functions, we can create our own functions.
A function is a block of statements that can be used repeatedly in a program.
A function will not execute immediately when a page loads.
A function will be executed by a call to the function
function functionName() {
code to be executed;
}
<?php
function writeMsg() {
echo "Hello world!";
}
<?php
function familyName($fname) {
echo "$fname Refsnes.<br>";
}
familyName("Jani");
familyName("Hege");
familyName("Stale");
familyName("Kai Jim");
familyName("Borge");
?>
<html>
<body>
</body>
</html>
The code above will register the user's session with the server, allow you to start
saving user information, and assign a UID for that user's session.
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?>
Destroying a Session
If you wish to delete some session data, you can use the unset() or the
session_destroy() function. The unset() function is used to free the specified session
variable:
<?php
session_start();
if(isset($_SESSION['views']))
unset($_SESSION['views']);
?>
You can also completely destroy the session by calling the session_destroy()
function:
<?php
session_destroy();
?>
session_destroy() will reset your session and you will lose all your stored session
data.
From security point of view, server-side scripts are never visible to the browser as these
scripts are executes on the server and emit HTML corresponding to user's input to the
page.
When the server serves data in a commonly used manner, for example according to
the HTTP or FTP protocols, users may have their choice of a number of client programs
(most modern web browsers can request and receive data using both of those protocols).
In the case of more specialized applications, programmers may write their own server,
client, and communications protocol, that can only be used with one another.
Programs that run on a user's local computer without ever sending or receiving data over
a network are not considered clients, and so the operations of such programs would not
be considered client-side operations.
<?php
$x = $_GET['prime'];
?>
<html>
<head>
<title>TEST</title>
</head>
<body>
<form method="GET" action="prime.php">
<input type="text" name="prime" />
<input type="submit" value="submit" />
<form>
<?php
for($j=1;$j<=$x;$j++){
$count = 0;
if(floor($j/2)*2 == $j/2*2){
//this will prevent the number 2 from outputting but 2 is a known prime so its ok
}
else{
for($i=1;$i<=$j;$i++){
$y = $j/$i;
$z = floor($j/$i);
if($y == $z){
$count+=1;
$array[$i] = $y;
}
}
}
Example 2. A web application that takes name and age from an HTML page. If the age
is less than 18, it should send a page with “hello <name>,and u are not authorized to
visit this site” otherwise it should send “welcome <name> to this site” message where
name should be replaced with the entered name otherwise it should send
welcome<name> to the site.
Form2.html
<form action='home.php'
method='post'> Login<br>
<input type='submit'value='Login'>
<?php
$name = $_POST['name'];
$age = $_POST['age'];
print "Hello " . $name . " you are not authorized to visit this site.";
else
?>
Conclusion:-
Industrial Applications :- PHP is a scripting language designed for developing dynamic web
pages. While its principal purpose was server-side scripting, it has grown to incorporate a
command line interface capability and can be used to develop client-side Graphical User
Interface (GUI) applications as well.
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
Questionnaire
1. What does PHP stand for?
2. PHP server scripts are surrounded by delimiters, which?
3. How do you write "Hello World" in PHP
4. All variables in PHP start with which symbol?
5. What is the correct way to end a PHP statement?
6. The PHP syntax is most similar to which programming language?
Objective : This lab gives a basics of PHP and MySQL Database(both are the most popular
open source technologies)
Theory:
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
A PHP script is executed on the server, and the plain HTML result is sent back to the browser.
<?php
?>
A PHP file normally contains HTML tags, and some PHP scripting code.PHP statements end
with a semicolon (;).
$row['row name'] - the value of the column in the current query. It is represented as an array.
In our case $row is the name of the variable for our row in the loop.
Steps:
Result:-
Conclusion:-
Industrial Applications :-
Digital Ad banners, where the PHP script can be used to retrieve a digital banner from the
database, which then selects a random banner from its table records and sends it back to the
calling script. The PHP script can also maintain a count of banner views and clicks from the
website. Internet forums or digital boards, which use PHP and MySQL to store and retrieve
user messages.
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
5. Mike Mcgrath, ―PHP & MySQL in easy Steps‖, Tata McGraw Hill, 2012.
Questionnaire
1. What is MySQL?
2. What is the advantage of MySQL?
3. How will you close a MySql database using PHP?
4. How can we communicates with MySQL server?
5. How can you connect to MySQL from PHP?
6. What is the use of mysql_query() function ?
7. How can we create a database using PHP and MySQL?
8. Explain phpMyAdmin?
9. How to repair a table in MySQL ?
10. What is a trigger and does MySQL support triggers ?
Objectives:
Objective is to learn about basics of XML and how it can be used to store information away
from the mechanism of processing or formatting of such data. Will also learn how to build
simple XML files and be able to manipulate and refer to them.
Scope: Encode the data with XML that allows the programs to share the data.
Theory:
XML (extensible Markup Language) is a markup language. XML is designed to store and
transport data. Xml was released in 1998. It was created to provide an easy to use and store self-
describing data. XML is not a replacement for HTML.XML is designed to be self-
descriptive.XML is designed to carry data, not to display data.XML tags are not predefined.
You must define your own tags.XML is platform independent and language independent. The
main benefit of xml is that you can use it to take data from a program like Microsoft SQL,
convert it into XML then share that XML with other programs and platforms. You can
communicate between two platforms which are generally very difficult. The main thing which
makes XML truly powerful is its international acceptance. Many corporation use XML
interfaces for databases, programming, office application mobile phones and more. It is due to
its platform independent feature.
Features and Advantages of XML:-
1) XML separates data from HTML
2) XML simplifies data sharing
3) XML simplifies data transport
4) XML simplifies Platform change
5) XML increases data availability
6) XML can be used to create new internet languages
The Difference between XML and HTML
XML and HTML were designed with different goals: XML was designed to carry data - with
focus on what data is HTML was designed to display data - with focus on how data looks XML
tags are not predefined like HTML tags. An XSL style sheet is, like with CSS, a file that
describes how to display an XML document of a given type. XSL shares the functionality and is
compatible with CSS2 (although it uses a different syntax). It also adds: A transformation
language for XML documents: XSLT.
Although there are countless numbers of applications that use XML, here are a few examples of
the current platforms and applications that are making use of this technology:
Cell Phones - XML data is sent to some cell phones. The data is then formatted by the
specification of the cell phone software designer to display text or images, and even to
play sounds!
File Converters - Many applications have been written to convert existing documents
into the XML standard. An example is a PDF to XML converter.
Voice XML - Converts XML documents into an audio format so that you can listen to an
XML document.
If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE>
definition:
<?xml version="1.0"?>
<!DOCTYPE note[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>
<?xml version="1.0"?>
<!DOCTYPE note[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
XML document:
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
DTD file:
And here is the file "note.dtd", which contains the DTD:
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
!DOCTYPE note defines that the root element of the document is note
!ELEMENT note defines that the note element must contain the elements: "to, from,
heading, body"
!ELEMENT to defines the to element to be of type "#PCDATA"
!ELEMENT from defines the from element to be of type "#PCDATA"
!ELEMENT heading defines the heading element to be of type "#PCDATA"
!ELEMENT body defines the body element to be of type "#PCDATA"
Result:-
Industrial Applications :-
XML allows a standard way of searching, displaying, manipulating, and exchanging data on the
Web. It can also be used to identify, exchange, and process distributed data in different
applications.
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
Questionnaire
1. What is XML?
2. How XML is different from HTML?
3. What is the meaning of version in XML?
4. What are the benefits of XML?
5. Elaborate XML DOM?
6. State SAX in XML?
7. Explain XSNL?
8. What is a well formed XML document?
9. What is a valid XML document?
10. What is DTD?
Objective : Students will be able to develop web pages using Ajax and PHP,
Scope: Use AJAX to create asynchronous, interactive web applications with the help of XML
HTML CSS and JavaScript
Theory: AJAX is about updating parts of a web page, without reloading the whole page.
What is AJAX?
AJAX allows web pages to be updated asynchronously by exchanging small amounts of data
with the server behind the scenes. This means that it is possible to update parts of a web page,
without reloading the whole page.
Classic web pages, (which do not use AJAX) must reload the entire page if the content should
change.
Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.
PHP files can contain text, HTML, CSS, JavaScript, and PHP code
PHP code are executed on the server, and the result is returned to the browser as plain
HTML
PHP files have extension ".php"
With PHP you are not limited to output HTML. You can output images, PDF files, and even
Flash movies. You can also output any text, such as XHTML and XML.
Result:-
Conclusion:-
The most recent development capturing the attention of the browser based application
developers is AJAX (Asynchronous JavaScript and XML). Integrating AJAX models into the
browser based GIS (Geographic Information Systems) Visualization Web Services systems.
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. Robin Nixon, "Learning PHP, MySQL, JavaScript, CSS & HTML5" Third Edition,
O'REILLY,2014.
5. Professional Rich Internet Applications: AJAX and Beyond, Dana Moore, Raymond Budd,
Edward Benson, Wiley publications.
6. https://ebooks-it.org/0470082801-ebook.htm
Questionnaire
1. What is Ajax?
2. Why Ajax is used?
3. What files need to install to use Ajax in Website?
4. What library are available to use the Ajax?
5. What Browsers support Ajax?
6. How we can send data to server using Ajax?
7. State advantage of AJax?
8. Explain the disadvantage of Ajax?
9. Define JSON?
10.What is Asynchronous in Ajax?
Objective: To learn the students after creation of website how to make it available online for
everyone.
Scope: The swelling wave of e-Commerce dominance fueling the need for organizations to
establish their online presence has led to the emergence of Web Designing as an important
organizational function
Theory:
After the website is created, the next step is to publish it. Publish in a website means making it
available online for everyone. To make a website available, you need to follow the following
steps.
Domain Name Registration Process
First you have to choose a domain name, then you need to submit your domain name
registration request to a registrar.
We need to submit the following information to the registrar:
Once after providing information to registrar, he will then initiate the domain name registration
process for you. The registrar will send your domain name request, and the contact and technical
information of the domain name to the registry.
The registry files the contact information for the Whois. The registry also adds your domain
zone files to the master servers. These master servers tell other servers on the Internet where
your website is stored.
Your domain is considered registered and ready-to-use when all information has been updated.
Web Hosting:
Web hosting is a service that allows organizations and individuals to post a website or web page
onto the Internet. A web host, or web hosting service provider, is a business that provides the
technologies and services needed for the website or webpage to be viewed in the Internet.
Websites are hosted, or stored, on special computers called servers.
When Internet users want to view your website, all they need to do is type your website address
or domain into their browser. Their computer will then connect to your server and your
webpages will be delivered to them through the browser.
Most hosting companies require that you own your domain in order to host with them. If you do
not have a domain, the hosting companies will help you purchase one.
Website Builders
Shared Hosting
Dedicated Hosting
Collocated Hosting
Step 6: Click on the verification link, you will get a profile page to be updated
WEB HOSTING
Step 2: Sign up and enter the domain name you purchased from freenom & click on Get free hosting
Step 4: After you click on Manage website you will get following 3 options for building your website
Step 6: Select Folder public_html and then select upload files icon on top right corner amongst the 8
icons given. You will get the following pop up message
Note: Name your first file as index.html otherwise it will not display the website
Step 10: website will appear under Build Website statement just click you will be directed to your web
page.
•Step 1 of 11
Log into the customer (cPanel) portal at https://[[IP Address]]:2083, Replacing [[IP Address]]
with the IP address for your server provided in your welcome email.
• Step 2 of 11
Step 3 of 11
Step 4 of 11
Select the Web Root (public_html/www) option and press the Go button.
Step 5 of 11
Step 6 of 11
Step 7 of 11
Web Design Lab (CPL504) 80
Press the Browse button to select the file you wish to upload.
Step 8 of 11
Navigate to the file you wish to upload and press the Open button.
Step 9 of 11
Step 10 of 11
Step 11 of 11
You will now see your uploaded file in your File Manager screen.
Then repeat steps 6 to 11 until you have uploaded all the required files.
Result:-
Conclusion:-
Industrial Applications :-
Marketing
Organaisation
1. www.nptelvideos.in
2. www.w3schools.com
3. http://spoken-tutorial.org
4. https://www.123-reg.co.uk/support/servers/uploading-your-website-in-cpanel-guide/
5. https://www.thehostingwebsite.com/website-hosting-process/
6. https://mail.google.com/mail/u/0/#search/akasharunsahu%40gmail.com/164383b78965fb
fe?projector=1&messagePartId=0.2
Questionnaire
Laravel Framework
Title: Design a Web application using Laravel Framework
Objective : Learner will be able to design a web application using a Laravel Framework
Scope: Develop more elegant and expressive web application following the model view
controller architectural pattern using Laravel.
Theory:
Laravel happens to be a very popular framework that is meant for developing PHP applications.
It comes across as a very clean and good framework for developing web applications.
Considering that developing applications should be a wonderful experience, Laravel is fairly
simple and allows for expressive syntax.
Also, another very good aspect of using Laravel is that it frees you from using spaghetti code.
Developers who have used Laravel always state that it brings forward three very important
qualities.
Simple in nature – several functionalities that Laravel offers is very simple to grasp and
understand. If you love simple programming style, you‟d surely stick with Laravel.
Fairly elegant – Even with very little configuration involved, Laravel‟s functions are
known to run seamlessly. It also relies on conventions specified in the industry that
allows or the prevention of code-bloating.
Very well-documented – Laravel always offers updated and complete documentation.
The creator even updates the documentation before a new version is released. This
makes it pretty easy for people who are just learning the framework.
Now that we just about have an idea about Laravel is, we shall go ahead and build a web
application. Here, we shall basically build an Instagram-like application, which will allow us to
post photos and also like and comment on them. Besides, you can also follow others.
Requirements
Download Xampp
Step 3:you will get Command line PHP screen it will be automatically selected.
click Next
Step 4: Proxy URL Screen. No need to enter anything. Just Click Next.
Conclusion:-
Industrial Applications :- Laravel has emerged as the most reliable framework as it offers unique
features and functionalities that can be used to create scalable web applications.
References:
1. www.nptelvideos.in
2. www.w3schools.com
3. 3.http://spoken-tutorial.org
4. https://laravel-news.com/your-first-laravel-application
5. https://www.codementor.io/magarrent/how-to-install-laravel-5-xampp-windows-du107u9ji
6. https://www.youtube.com/watch?v=1exF0kNKCvQ&t=222s
Questionnaire
1.What is Laravel ?
2. List some official packages provided by Laravel?
3. List out latest features of Laravel.
4. List out some benefits of Laravel over other Php frameworks.
5.What is composer ?
6. How to install laravel via composer ?
7. How to check laravel current version ?
8. What is Lumen?
9 What are Advantages of Laravel?
10 What are the feature of Laravel5.0?