Agam Raj LabFile
Agam Raj LabFile
LAB FILE
Web Technology Lab (BCSE0555)
Submitted By Submitted to
1. Implementing HTML program that represent in the document as a start tag, which gives the
name and attributes.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Question1</title>
</head>
<body>
<div>
<hl>Welcome to first HTML code.</hl>
<h2>This is used for subheading.</h2>
<h3>This is 3rd largest heading!</h3>
<h4>This is 4th largest heading!</h4>
<hS>This is 5th largest heading!</hS>
<h6>Smallest heading! !</h6>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>HTML Document</title>
</head>
<body>
<header>
<hl>Welcome</hl>
</header>
<main>
<h2>About the Page</h2>
<p>This is a simple HTML document that includes basic elements like a header, main content area,
and footer. It demonstrates the fundamental structure of an HTML page.</p>
<p>You can add more content here, such as images, links, and lists.</p>
</main>
<footer>
<p>© Website</p>
</footer>
</body>
</html>
<body>
<div class="container">
<hl>Anushka Tiwari</hl>
<p><strong>Email:</strong> xyz@[Link] I <strong>Phone:</strong> 355 477
566</p>
<p><strong>Location:</strong>Address</p>
<hr> <div>
<h2 class="section-title">Education</h2>
<ul> <Ii>
<strong>Bachelor of Science in Computer Science</strong> <br>
University of Example, 2022 - 2026
</Ii> <Ii>
<strong>High School Diploma</strong> <br>
Example High School, 2020 - 2022
</Ii> </ul> </div> <hr> <div>
<h2 class="section-title">Work Experience</h2>
<ul>
<Ii>
<strong>Software Developer</strong> <br>
Tech Company, Anytown, 2026 <br>
<em>Responsibilities:</em> Developed web applications, managed databases,
and collaborated with teams to implement software solutions.
</Ii>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Document</title>
<style>
.day
{
text-align:center;
font-family:Arial, Helvetica, sans-serif;
}
.period
{
text-align:center;
font-family: Arial, Helvetica, sans-serif;
padding-left:lOOpx;
border-collapse: collapse;
}
.head
{
justify-content: center;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
text-align: center;
}
.tab
{
text-align: center;
font-style: oblique;
</style>
</head>
<body>
<hl class="head">Time Table</hl>
<table border="2" class="tab">
<tr>
<th class="day">Day/Period</th>
<th>l<br>9:30-10:20</th>
<th>ll<br>10:20-11:10</th>
<th>lll<br>ll:10-12:00</th>
<th>l2:00-12:40</th>
<th>IV<br>12:40-01:30</th>
<th>V<br>0l:30-02:20</th>
<th>Vl<br>02:20-03:10</th>
<th>Vll<br>03:10-04:00</th>
</tr>
<tr>
<td class="day">Monday</td>
<td class="Period">Eng</td>
<td class="Period">Math</td>
<td class="Period">Chem</td>
<td class="Period" rowspan="6"></td>
<td class="Period"colspan="3">LAB</td>
<td class="Period">Phy</td>
</tr> <tr>
<td class="day">Tuesday</td>
<td class="Period" colspan="3">LAB</td>
<td class="Period">Eng</td>
<td class="Period">Chem</td>
<td class="Period">Math</td>
<td class="Period">Sports</td>
</tr> <tr>
<td class="day">Wednesday</td>
<td class="Period">Mat</td>
<td class="Period">Phy</td>
<td class="Period">Eng</td>
<td class="Period">Che</td>
<td class="Period" colspan="3">Library</td>
</tr> <tr>
<td class="day">Thursday</td>
<td class="Period">Phy</td>
<td class="Period">Eng</td>
<td class="Period">Chem</td>
<td class="Period" colspan="3">LAB</td>
<td class="Period">Mat</td>
</tr> <tr>
<td class="day">Friday</td>
<td class="Period" colspan="3">LAB</td>
<td class="Period">Mat</td>
<td class="Period">Che</td>
<td class="Period">Eng</td>
<td class="Period">Phy</td>
</tr>
<tr>
<td class="day">Satday</td>
<td class="Period">Eng</td>
<td class="Period">Chem</td>
<td class="Period">mat</td>
<td class="Period" colspan="3">Seminar</td>
<td class="Period">Sports</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Question 6</title>
</head>
<body>
<hl>Paragraph and Line Break</hl>
<p>This is the first paragraph. It contains some text to demonstrate how paragraphs are used
in HTML.</p>
<p>This is the second paragraph. HTML paragraphs are block-level elements, which
means they start on a new line and have some space before and after them.</p>
<p>This is the third paragraph. You can also use line breaks to control where the text moves
to a new line.</p>
<p>This sentence ends here,<br>and this sentence starts on a new line because of the line
break.</p>
<p>Another example of a line break:<br>Here is the text on the new line.</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Question</title>
</head>
<body>
<div class="containerl">
<hl>Welcome to first HTML code.</hl>
<h2>This is used for subheading.</h2>
<h3>This is 3rd largest heading!</h3>
<h4>This is 4th largest heading!</h4>
<hS>This is 5th largest heading!</hS>
<h6>Smallest heading! !</h6>
</div>
</body>
</html>
8. Use tables to provide layout to your HTML page describing your college infrastructure.
<!DOCTYPE html>
<html lang="en">
<head>
<title>College lnfrastructure</title>
</head>
<body>
<hl>College Infrastructure Overview</hl>
<table border="l" cellpadding="l0" cellspacing="0">
<tr>
<th>Section</th>
<th>Description</th>
</tr>
<tr>
<td>Library</td>
<td>The college library is equipped with thousands of books, journals, and e-resources. It
provides a quiet space for study and research.</td>
</tr>
<tr>
<td>Laboratories</td>
<td>State-of-the-art labs for Physics, Chemistry, Biology, and Computer Science provide
practical experience and hands-on learning.</td>
</tr>
<tr>
<td>Classrooms</td>
<td>AII classrooms are spacious, well-ventilated, and equipped with modern teaching
aids like projectors and smart boards.</td>
</tr>
<tr>
<td>Sports Facilities</td>
<td>Our campus includes a gymnasium, football field, basketball court, and indoor sports
facilities to encourage physical fitness and sportsmanship.</td>
</tr>
<tr>
<td>Hostel</td>
<td>The college hostel provides comfortable accommodation with all essential amenities,
ensuring a home-like environment for students.</td>
</tr>
<tr>
<td>Cafeteria</td>
<td>The cafeteria offers a variety of healthy and tasty food options, catering to diverse
tastes and dietary requirements.</td>
</tr>
</table>
</body>
</html>
0
0 127 0.0.1 5SOO/a1<i nmeel/quesa hlml 0.. A' 0
C'Lli.!mt:lm! AU [Link]'D:S an! !1',111!'°'1!1. 'l.\ J.l!.\![Link]. 11!1.C! fqll[fped 'll.1[1.!1modt!l'II !i:![Link]:f llld1lll:t! pttiJertor.1 aJltl.!mot ltCrardl..
Sp«IJ FIJciliti Owtll,IJJpl9 iocJL1liel; ■ i)'[Link]:lu.m. (tl<llblU fie:ltl, bllf!_ tt:iitl.l,ca,111,. •ltd itldni.'!r:tparl!! l]i1iie, fool!fWl:l0\11:l,P.i!- pll)•s;ir:tl [itlld$ ptt odlip.
Ho!.ttl TtWi coUt-gt M!tel llt\Wldt-! comfill'Ulble IU' [Link] «lri ...,,[tb [Link] !:::Wfillil atu l!lkia ffl3Utln.(!! 1 llkif;,ci:\•lr<lmru!at for ,mdtttt:t.
9. Use <span> and <div> tags to provide a layout to above page instead of a table layout.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>College lnfrastructure</title>
</head>
<body>
<hl>College Infrastructure Overview</hl>
<div style="margin-bottom: 20px;">
<div style="font-weight: bold;">Library</div>
<div>The college library is equipped with thousands of books, journals, and e-resources. It
provides a quiet space for study and research.</div>
</body>
</html>
10. Apply various colours to suitably distinguish keywords, also apply font styling like
italics, underline and two other fonts to words you find appropriate, also use header
tags.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Quesl0</title>
</head>
<body>
</body>
</html>
11. Create a webpage with HTML describing your department use paragraph and list tags.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
.tag
{
position:relative;
border-image: round;
border-radius: 4cm;
margin-top: l0px;
margin-left: 400px;
margin-right: lO0px;
}
.head
{
text-align:center;
font-family:'Courier New', Courier, monospace;
color: rgb{32, 118, 65);
}
</style>
</head>
<body>
<nav>
<img src="[Link]" height="250" width="400" class="tag">
<h3 class="head">Friendship Zone</h3>
<hS>A place to find like minded people......</hS>
<p>
<quote>One of the most beautiul qualities of true friendship is to undertand and to be
understood.</quote>
</p>
<pre> A real friend is one who Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Delectus sed a laboriosam, ilia quas explicabo, aut autem vero sunt ea suscipit earum, sint porro
incidunt odio perferendis! Quo, nam deleniti.</pre>
<hr>
<ul>
<li><a href="[Link]">Click to Search Friends</a></li>
<li><p>Send for your suggestions. <a
href="[Link]">Support@[Link]</a></p></li>
</ul>
</body>
</html>
•Cld•loobl!K141
,S!n,lf )tllrlll!Jolioa!. -
12. Create links on the words e.g. -WIFI and -LAN to link them to Wikipedia pages.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Networking lnformation</title>
</head>
<body>
<hl>Networking lnformation</hl>
</body>
</html>
13. Insert an image and create a link such that clicking on images takes user to other page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Delicious Foods Around the World</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; }
article { margin: 20px; padding: 15px; background: #f9f9f9; border: lpx solid #ddd;}
hl { color: #333; }
img { max-width: 100%; height: auto; border: lpx solid #ddd; }
</style>
</head>
<body>
<article>
<hl>Delicious Food</hl>
<p><a href="[Link]," target="_blank">
<img src="[Link]" alt="Delicious Food">
</a></p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos quas quisquam cum
eveniet nostrum corporis aperiam dolor iure possimus unde.</p>
<h2>Traditional Foods</h2>
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Hie temporibus ipsam sit.
Eligendi temporibus, sapiente quae cumque quia quam nostrum?</p>
<h2>Famous Food</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Possimus autem itaque quos
perferendis qui unde cumque blanditiis magnam maiores voluptatibus?</p>
</article>
</body>
</html>
14. Change the background color of the page; At the bottom create a link to take user to the top of
the page.
<!DOCTYPE html>
<html>
<head>
<title>quesl4</title>
<style>
body{
background-color: #f2f2f2;
margin: 0;
padding: 0;
font-family: Arial, sans-serif;}
#backToTop {
position: fixed;
bottom: 20px;
right: 20px;
display: none;}
#backToTop a
{ background-color:
#333; color: white;
padding: lOpx 15px;
text-decoration: none;
border-radius: 5px;}
#backToTop a:hover
{ background-color:
#555;}
</style>
<script>
[Link] = function()
{ scrollFunction() };
function scrollFunction() {
if ([Link] > 20 11 [Link] > 20)
{ [Link]("backToTop").[Link] = "block";
} else {
[Link]("backToTop").[Link] = "none";}
}
function scrollToTop()
{ [Link] = 0;
[Link] = 0;}
</script>
</head>
<body>
[(fJ tr:] I [') College Infra X I [') Ques10 X I [') Document X I [') Networking X I
Ci CD [Link]:5500/assignment/[Link]
[Link] frames such that pages is divided into 3 frames 20% on left to show contents of pages,
60% in centre to show contents of pages.
<!DOCTYPE html>
<html>
<head>
<title>Frame Example</title>
</head>
</frameset>
</html>
16. Design a HTML registration form that takes user name, user password and mobile number with
submit button control.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=" UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Registration Form</title>
<style>
.tag
{
position:relative;
border-image: round;
border-radius: 4cm;
margin-top: lOpx;
margin-left: 400px;
margin-right: lO0px;
}
.head
{
text-align:center;
font-family:'Courier New', Courier, monospace;
color: rgb(32, 118, 65);
}
</style>
</head>
<body>
<img src="[Link]" height="250" width="400" class="tag">
<h3 class="head">Friendship Zone</h3>
<h4>Add your details tp register</h4>
<nav>
Name: <input type="text" name="name"><br><br>
Email: <input type="email" name="email"><br><br>
Age: <input type="number" name="name"><br><br>
Birth Day: <input type="datetime-local" name="dob"><br><br>
Gender: <input type="checkbox">M
<input type="checkbox">F
<br><br>
About: <textarea rows="3" cols="30" aria-valuemax="200"></textarea>
<br><br>
Phone: <input type="number" aria-valuemax="l0"><br><br>
<br>
<hS>lnterested in:</hS>
<input type="checkbox">Friendship
<input type="checkbox">Dating
<br><br>
<b>Attachemnt:</b>
<input type="file" name="file">
<br><br>
<a href="[Link]"><input type="submit" value="Register"></a>
<a href="[Link]"><input type="subm it" value="Register to
admin"></a>
</nav>
</body>
</html>
17. Design a HTMLS document that implement of date, number, range, email, search and data list.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=" UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.0">
<title>Quesl7</title>
</head>
<body>
<hl>Form :</hl>
<form>
<label for="date">Date:</label>
<input type="date" id="date" name="date"><br>
<label for="number">Number:</label>
<input type="number" id="number" name="number" min="l" max="l0"><br>
<label for="range">Range:</label>
<input type="range" id="range" name="range" min="0" max="l00" value="S0"><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br>
<label for="search">Search:</label>
<input type="search" id="search" name="search"><br>
<label for="datalist">Fruit:</label>
<input list="fruits" id="datalist" name="datalist">
<datalist id="fruits">
<option value="Apple">
<option value="Banana">
<option value="Cherry">
</datalist><br>
<button type="submit">Submit</button>
</form>
</body>
</html>
18. Implementation in HTMLS that include native audio and video support without the need for Flash.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTMLS Audio and Video</title>
</head>
<body>
<hl>HTMLS Audio and Video display</hl>
<h2>Audio</h2>
<audio controls>
<source src="audiol.mp3" type="audio">
Your browser does not support the audio element.
</audio>
<h2>Video</h2>
<video controls width="600">
<source src="file1.mp4" type="video/mp4">
Your browser does not support the video element.
</video>
</body>
</html>
19. Creating HTML program to implement three articles with independent, self-contained content.
<!DOCTYPE html>
<html>
<head>
<title>Three Articles</title>
<style>
body{
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
.article {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color:
#ffffff; border-radius:
8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<div class="article">
<h2>Article 1: Introduction to HTML</h2>
<p>HTML (HyperText Markup Language) is the standard markup language for creating web pages. It
structures content using elements such as headings, paragraphs, lists, and links.</p>
</div>
<div class="article">
<h2>Article 2: CSS Basics</h2>
<p>CSS (Cascading Style Sheets) is used to control the presentation and layout of web pages. It
allows you to apply styles like colors, fonts, spacing, and positioning to HTML elements.</p>
</div>
<div class="article">
<h2>Article 3: JavaScript Fundamentals</h2>
<p>JavaScript is a versatile programming language that adds interactivity and dynamic behavior to
web pages. It can be used to create animations, validate forms, and manipulate the DOM.</p>
</div>
</body>
</html>
11
<?xml version="l.0" encoding="UTF-8 ?>
<CV>
<Info>
<Name>John Doe</Name>
<Email>john@[Link]</Email>
<Phone>123-456-7890</Phone>
</Info>
<Education>
<School>
<Degree>Bachelor</Degree>
<Major>Computer Science</Major>
<Year>2022</Year>
</School>
<School>
<Degree>Master</Degree>
<Major>Software Engineering</Major>
<Year>2024</Year>
</School>
</Education>
<Skills>
<Skill>Java</Skill>
<Skill>Python</Skill>
<Skill>HTML</Skill>
<Skill>CSS</Skill>
</Skills>
</CV>
21. Designing XML document that store various book data such as: book category, title, author, year
and price.
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body{
font-family: Arial, sans-
serif; line-height: 1.6;
padding: 20px;
}
h2 {color: #333;}
ul { list-style-type: square;}
</style>
</head>
<body>
<hl>XML</hl>
<ul>
<li><strong>Elements:</strong> The building blocks of an XML document, defined by start
and end tags. Example: <code><name>John</name></code>.</li>
<li><strong>Attributes:</strong> Provide additional information about elements and are
included within the start tag. Example: <code><person age="30"></code>.</li>
<li><strong>Prolog:</strong> The first line in an XML document that includes the XML
declaration. Example: <code><?xml version="l.0" encoding="UTF-8"?></code>.</li>
<li><strong>Comments:</strong> Notes or explanations within an XML document that are
not processed. Example: <code>< !-- This is a comment --></code>.</li>
<li><strong>CDATA Sections:</strong> Used to include content that should not be parsed
by the XML parser. Example: <code><![CDATA[Some content here]]></code>.</li>
</ul>
</body>
</html>
23. Design XML DTD to define the structure and legal element and attribute of XML document
<!DOCTYPE library [
<!-- Define the book element-->
<!ELEMENT book (title, author, year, genre?, price?)>
<!-- Define the title, author, year, genre, and price elements-->
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!-- Define the isbn attribute for the book element-->
<!ATTLIST book isbn CDATA #REQUIRED>
<!-- Define the language attribute for the book element-->
<!ATTLIST book language (English I Spanish I French I German) "English">
<!-- Define the publisher attribute for the book element-->
<!ATTLIST book publisher CDATA #IMPLIED>]>
</company>
<company>
<name>Reliance lndustries</name>
<industry>Conglomerate</industry>
<headquarters>Gujarat</headquarters>
</company>
<company>
<name>lnfosys</name>
<industry>IT Services</industry>
<headquarters>Bangalore</headquarters>
</company>
</companies>
External DTD :
(DTD File)
<!ELEMENT companies (company+)>
<!ELEMENT company (name, industry, headquarters)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT industry (#PCDATA)>
<!ELEMENT headquarters (#PCDATA)>
(XML File)
<?xml version="l.0" encoding="UTF-8"?>
<!DOCTYPE companies SYSTEM "[Link]">
<companies>
<company>
<name>Tata Consultancy Services</name>
<industry>IT Services</industry>
<headquarters>Mumbai</headquarters>
</company>
<company>
<name>Reliance lndustries</name>
<industry>Conglomerate</industry>
<headquarters>Gujarat</headquarters>
</company>
<company>
<name>lnfosys</name>
<industry>IT Services</industry>
<headquarters>Bangalore</headquarters>
</company>
</companies>
25. Design a XML Schema that describes the structure of an XML document.
([Link])
<?xml version="l.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="[Link]
<!-- Define the root element-->
<xs:element name="states">
<xs:complexType>
<xs:sequence>
<xs:element name="state" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="capital" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
(XML File)
<?xml version="l.0" encoding="UTF-8"?>
<states xmlns:xsi="[Link] LSchema-insta nee"
xsi:noNamespaceSchemalocation="[Link]">
<state>
<name>Maharashtra</name>
<capital>Mumbai</capital>
</state>
<state>
<name>Karnataka</name>
<capital>Bangalore</capital>
</state>
<state>
<name>Tamil Nadu</name>
<capital>Chennai</capital>
</state>
</states>
26. Design a XML document that describe the well-formed XML document.
27. Design a XML document of CD Catalog through each <CD> element, and displays
the values of the <ARTIST> and the <TITLE> elements in an HTML table.
28. Create a XSL document for and taken xml document by you.
?xml version="1.0" encoding="UTF-8"?>
<CD_catalog>
<CD>
<ARTIST>Michael Jackson</ARTIST>
<TITLE>Thriller</TITLE>
</CD>
<CD>
<ARTIST>The Beatles</ARTIST>
<TITLE>Abbey Road</TITLE>
</CD>
<CD>
<ARTIST>Queen</ARTIST>
<TITLE>A Night at the Opera</TITLE>
</CD>
</CD_catalog>
29. Create a XSLT document for and taken xml document by you with all steps.
<!DOCTYPE html>
<html>
<head>
<title>CD Catalog</title>
</head>
<body>
<hl>CD Catalog</hl>
<table border=" l ">
<!-- Use JavaScript to load the XML and XSLT files and apply the transformation-->
<script>
// Load the XML document
var xml = new XMLHttpRequest();
[Link]("GET", "cd_catalog.xml", false);
[Link]();
var xmlDoc = [Link];
// Load the XSLT document
var xslt = new XMLHttpRequest();
[Link]("GET", "cd_catalog.xsl", false);
[Link]();
var xsltDoc = [Link];
// Transform the XML with the XSLT
var xsltProcessor = new XSLTProcessor();
[Link](xsltDoc);
var resultDocument = [Link](xmlDoc, document);
II Append the transformed content to the body
[Link](resultDocument);
</script>
</table></body>
</html>
30. Create a simple form to submit user input like his name, age, address and
favourite subject, movie and singer.
<!DOCTYPE html>
<html>
<head>
<title>User Input Form</title>
</head>
<body>
<hl>User Input Form</hl>
<form action="process_form.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required><br>
<label for="address">Address:</label>
<input type="text" id="address" name="address" required><br>
</html>
31. Add few form elements such as radio buttons, check boxes and password field. Add
a submit button at last.
<!DOCTYPE html>
<html>
<head>
<title>Form with Elements</title>
</head><body>
<hl>Form with Elements</hl>
<form>
<label>
<input type="radio" name="gender" value="male"> Male
</label>
<label>
<input type="radio" name="gender" value="female"> Female
</label>
<label>
<input type="radio" name="gender" value="other"> Other
</label> <br>
<label>
<input type="checkbox" name="interests" value="sports"> Sports
</label>
<label>
<input type="checkbox" name="interests" value="music"> Music
</label>
<label>
<input type="checkbox" name="interests" value="movies"> Movies
</label> <br>
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
32. Add CSS property assign a style or behaviour to an HTML element such as: color,
border, margin and font-style.
<!DOCTYPE html>
<html>
<head>
<title>CSS Properties Example</title>
</head>
<body>
<hl style="color: blue; border: 2px solid red; margin:
20px; font-style: italic;">CSS Properties Example</hl>
<p style="color: green; border: lpx solid black; margin: lOpx;
font-style: normal;">This is a paragraph with custom styles.</p>
</body>
</html>
33. Add To Style Text Elements with Font, Size, and Color in CSS.
<!DOCTYPE html>
<html>
<head>
<title>Text Styling Example</title>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
<body>
<hl class="title">Welcome to our website</hl>
<p class="paragraph">This is a sample paragraph with styled text.</p>
</body>
</html>
34. Applying a block element in CSS acquires up the full width available for that content.
<!DOCTYPE html>
<html>
<head>
<title>Block Element Example</title>
<style>
/* Styling for the block-level element */
.block-element {
background-color: #fDfDfD;
border: 1px solid #ddd;
padding: 10px;
/* The following properties ensure the element takes up the full width available */
display: block;
width: 100%;
box-sizing: border-box;
/* Includes padding and border in the total width*/
}
</style>
</head>
<body>
<div class="block-element">
This is a block-level element. It takes up the full width available within its containing block.
</div>
</body>
</html>
35. Resize an image to fit its content box, and position the image Spx from the left and
10% from the top inside the content boxes.
<!DOCTYPE html>
<html>
<head>
<title>Image Resize and Position</title>
<style>
/* Container for the image */
.image-container {
width: 300px;
/* Set the desired width of the content box*/
height: 200px;
/* Set the desired height of the content box */
position: relative;
/* Enable positioning for the contained image */
border: 1px solid #ccc;
/* Optional: Add a border for visual reference*/
}
/* Styling for the contained image*/
.image-container img
{ max-width:
100%;
/* Resize the image to fit its content box */
height: auto;
/* Maintain the aspect ratio */
position: absolute;
/* Position the image within the container */
top: 10%;
/* 10% from the top */
left: 5px;
/* 5px from the left */
}
</style>
</head>
<body>
<div class="image-container">
<img src="[Link]" alt="Resized and Positioned Image">
</div>
</body>
</html>
Information Technology, NIET Gr. Naida
Web Technology (BCSEOSSS) Lab Manual
.main-menu {
background-color: #fOfOfO;
padding: 1Opx;
}
.main-menu ul {
list-style-type: none;
margin: O;
padding: O;
}
.main-menu li
{ display: inline;
margin-right: l 5px;
}
.main-menu a {
text-decoration: none;
color: #333;
}
/* Apply styles to the main content area using the class selector*/
.content {
padding: 20px;
}
/* Apply styles to the footer using the class selector*/
.site-footer {
text-align: center;
padding: 1Opx;
background-color: #333;
color: #fff;
}
[Link]
box {
width: 200px;
height: l 50px;
background-color: #fOfOfO;
border: 2px solid #333;
padding: 20px;
margin: 50px;
}
My Website
• llllW<
• [Link]!!;
• Service;;
-
Featured Content
Thisis the foarured content of the website.
Latest News
Check out the latest news and updates.
Now, lel's crea1e the [Link] to apply styles. using both CSS ID and class selecmrs: f4 Apply styles ro the [Link] lirleusing the ID selector */#siie-title j font-size: 36px:color: F.333: }/*Apply styles to the main navigation menu
using the class selector•; .main.-menu ( backgro1md-<'olor: #filfOftl; padding: !Opx; ] .[Link] ul l [Link]-type: none; margin: 0: padding: O;}.main-menu li { display: inline: margin-right: 15px;} .main-menu a r rexr-
Jecorarion:
none: color: #333:} Applystyles to the main conlenl area using the class selector•j .content { padding: 20px: I ;-..Apply styie.s to the footer using the class selector*/ .site-foofer I text-align.: center: padding: lOpx: [Link]-i'.:olor:
#333:color:#fff:)
39. Demonstrating the CSS Box model which consists of: borders, padding, margins, and
the actual content.
<!DOCTYPE html>
<html>
<head>
<title>CSS Box Model Example</title>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
<body>
<div class="box">
This is the content of the box.
</div>
</body>
</html>
[Link]
box {
width: 200px;
height: l 50px;
background-color: #filfDfD;
border: 2px solid #333;
padding: 20px;
margin: 50px;
}
40. Design a web page by applying CSS grouping and dimensions property.
<!DOCTYPE html><html><head>
<title>CSS Grouping and Dimensions Example</title>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
<body>
<header>
<hl>My Website</hl>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<main>
<section>
<h2>Featured Content</h2>
<p>This is the featured content of the website.</p>
</section>
<section>
<h2>Latest News</h2>
<p>Check out the latest news and updates.<Ip>
</section>
</main>
<footer>
<p>© 2023 My Website. All rights reserved.</p>
</footer>
</body>
</html>
[Link]
box {
width: 200px;
height: l 50px;
background-color: #fOfOfO;
border: 2px solid #333;
padding: 20px;
margin: 50px;
}
41. Design a web page by applying CSS Display and Positioning property.
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="[Link]">
<title>Simple Layout</title>
</head>
<body>
<header>
<hl>Header</hl>
</header>
<div class="sidebar">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
<main>
<h2>Main Content</h2>
<p>This is the main content area.</p>
</main>
</body>
</html>
Output
Main Content
This is the main content area
42. Design a web page showing the use of inline, internal and external CSS.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=l.O">
<link rel="stylesheet" href="[Link]">
<title>CSS Examples</title>
</head>
<body>
<hl>This is a Heading</hl>
<p style="color: red;">This is a paragraph with inline CSS.</p>
<p>This is a paragraph with internal CSS.</p>
<p class="external-css">This is a paragraph with external CSS.</p>
</body>
</html>
Output
This is a Heading
This is a paragraph with inline
This is a paragraph with internal CSS
This is a paragraph with external CSS
[Link]
/* Basic styles for the navigation menu*/
nav ul {
list-style-type: none;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 20px;
}
nav ul Ii a {
text-decoration: none;
color: #333;
font-weight: bold;
font-size: 18px;
}
nav ul li a:hover {
color: #0074D9;}
Output
Home About Service Contact
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="[Link]">
<title>CSS Navigation Bar Example</title>
</head>
<body>
<nav class="navbar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</body>
</html>
[Link]
* Basic styles for the navigation bar*/
.navbar {
background-color: #333;
overflow: hidden;
}
.navbar ul {
list-style-type: none;
margin: O;
padding: O;
}
.navbar li {
float: left;
margin-right: 20px;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: background-color 0.3s ease;
}
/* Hover effect *I
.navbar li a:hover {
background-color: #0074D9;
}
Output
Home About Service Portfolio Contact
45. Design a web page such as home page, contact us, about us etc. by using 3 ways of
CSS layout.
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="[Link]">
<title>Layout Examples</title>
</head>
<body>
<header>
<hl>My Website</hl>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
</header>
<div class="content">
<section class="home">
<h2>Home Page</h2
<p>Welcome to our website! This is the home page content.</p>
</section>
<section class="about">
<h2>About Us</h2>
<p>cp>
</section>
<section class="contact">
<h2>Contact Us</h2>
<p>Feel free to reach out to us at contact@[Link]</p>
</section>
</div>
</body>
</html>
[Link]
/* Floats Layout */
.content {
overflow: hidden;
}
section {
float: left;
width: 33.33%;
box-sizing: border-box;
padding: 20px;
}
nav ul li {
display: inline;
margin-right: 20px;
}
Output:
Home Page
Welcome to our website! This is the home page content
Feel free to reach out to us at contact@[Link]
Output
This is column 1
This is column 2
This is column 3
Output
Bootstrap Typography
This is an example of Bootstrap typography
This is a muted text
This is a danger text
<script>
// Arithmetic Operators
let numl = 10;
let num2 = 5;
[Link]("Arithmetic Operators:<br>");
[Link]('numl + num2 = ${numl + num2}<br>');
[Link]('numl - num2 = ${numl - num2}<br>');
[Link]('numl * num2 = ${numl * num2}<br>');
[Link]('numl I num2 = ${numl / num2}<br>');
[Link]('numl % num2 = ${numl % num2}<br>');
[Link]('++numl = ${++numl}<br>');
[Link](' num2-- = ${num2--}<br><br>' );
// Assignment Operators
let x = 5;
let y= 3;
[Link]("Assignment Operators:<br>");
[Link]('x = ${x}<br>');
x+=y;
[Link]('x +=y: ${x}<br>');
x-= y;
[Link]('x -= y: ${x}<br> ');
X *=y;
// Comparison Operators
let a= 10;
let b = 5;
[Link]("Comparison Operators:<br>");
[Link]('a == b: ${a== b}<br>');
[Link]('a !=b: ${a !=b}<br>');
[Link]('a> b: ${a> b}<br>');
[Link]('a< b: ${a< b}<br>');
[Link]('a >= b: ${a>= b}<br> ');
[Link]('a <= b: ${a<= b}<br><br>');
// Logical
Operators let
isTrue = true; let
isFalse = false;
[Link]("Logical Operators:<br>");
[Link]('isTrue && isFalse: ${isTrue && isFalse}<br>');
[Link]('isTrue II isFalse: ${isTrue II isFalse}<br>');
[Link](' !isTrue: ${!isTrue}<br><br>' );
// Bitwise Operators
let bitwiseNuml = 5; // Binary:
0101 let bitwiseNum2 = 3; //
Binary: 0011
[Link]("Bitwise Operators:<br>");
[Link]('bitwiseNuml & bitwiseNum2: ${bitwiseNuml & bitwiseNum2}<br>'); II
AND
[Link]('bitwiseNuml I bitwiseNum2: ${bitwiseNuml I bitwiseNum2}<br>'); //
OR
[Link]('bitwiseNuml /\ bitwiseNum2: ${bitwiseNuml /\ bitwiseNum2}<br>'); II
XOR
[Link](' ~bitwiseNum1: ${~bitwiseNum1}<br>' ); // NOT
[Link]('bitwiseNuml << 1: ${bitwiseNuml << 1}<br>'); II Left Shift
[Link]('bitwiseNuml >> 1: ${bitwiseNuml >> 1}<br>'); II Right Shift
</script>
</body>
</html>
JavaScript Operators
Arithmetic Operators:
numl + num2 = 15
nmnl - nmn2 = 5
numl * nmu2 = 50
munl / mun2 = 2
muul % muu2 = 0
++numl = 11
mun2-- = 5
Assigmnent Operators:
x=5
x+=y: 8
x-=y: 5
X *= y: 15
x I= y: 5
X %=y: 2
[Link] Operators:
a =b: false
a!= b: t:tue
a>b: t:tue
a< b: false-
a >= b: t:t1.1e
a<= b: false
Logical Operators:
isTrue && isFalse: false
isTrue II isFalse: t:[Link]
! isTn1e: false
Bitwise. Opemtors:
bitwiseNuml & bitwiseNum2: I
bitwiseNuml I bit"vise um2: 7
bitwiseNurn.1 "bitv,-:ise um2: 6
bittviseNuml: -6
bitv,:iseNuml << 1: 10
bitwiseNuml >> 1: 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript 'var' Keyword</title>
</head>
<body>
<hl>JavaScript 'var' Keyword</hl>
<script>
// Using 'var' to declare and initialize variables
var firstName = "John";
var lastName = "Doe";
</script>
</body>
</html>
... ,..,_;,...... y1c::: L_J ............. 1'11111 .. ...._,II...JI t'. C::lllH y ...
SO. Implementing a Java Script program to implement onSelect and onload event.
<!DOCTYPE html><html><head>
<title>onSelect and onLoad Events</title>
</head>
<body>
<hl>onSelect and onLoad Events Example</hl>
<p>Select a color:</p>
<select id="colorSelect">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
<p id="selectedColor"></p>
<script>
// Function to handle the onSelect event
function onSelectChange() {
var select= [Link]("colorSelect");
var selectedColor = [Link][[Link]].value;
var selectedColorText = [Link][[Link]].text;
[Link]("selectedColor").innerHTML = "You selected: " + selectedColorText
+" (" + selectedColor + ")";
}
II Function to handle the onLoad event
function onLoad() {
[Link]("selectedColor").innerHTML = "Please select a color.";
}
// Attach the onSelect event handler to the select
element var select=
[Link]("colorSelect");
[Link]("change", onSelectChange);
// Attach the onLoad event handler to the window's load event
[Link]("load", onLoad);
</script>
</body>
</html>
51. Implementing a program in Java Script to create array by using array literal,
creating instance and array constructor.
</head><body>
<hl>Creating Arrays in JavaScript</hl>
<h2>Using Array Literal:</h2>
<script>
//Using Array Literal
var fruitsLiteral = ["Apple", "Banana", "Cherry"];
[Link]("Array created using Array Literal: " +
fruitsLiteral);
</script>
<h2>Using Array Instance:</h2>
<script>
//Using Array Instance
var fruitslnstance = new Array("Orange", "Grapes", "Strawberry");
[Link]("Array created using Array Instance:"+ fruitslnstance);
</script>
<h2>Using Array Constructor:</h2>
<script>
//Using Array Constructor
var fruitsConstructor = new Array();
fruitsConstructor[0] = "Peach";
fruitsConstructor[1] = "Mango";
fruitsConstructor[2] = "Watermelon";
[Link]("Array created using Array Constructor: "+ fruitsConstructor);
</script></body></htrnl>
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Loops</title>
</head>
<body>
<hl>JavaScript Loops</hl>
<h2>While Loop:</h2>
<script>
// Using a While
Loop var i = 1;
while (i <= 5) {
[Link]( Iteration + i + <br> );
11 11 11 11
i++;
}
</script>
<h2>Do-While Loop:</h2>
<script>
// Using a Do-While
Loop var j = 1;
do {
[Link]( Iteration + j + <br> );
11 11 11 11
j++;
} while (j <= 5);
</script>
<h2>For Loop:</h2>
<script>
// Using a For Loop
for (var k = 1; k <= 5; k++) {
[Link]( Iteration + k + <br> );
11 11 11 11
}
</script>
</body>
</html>
[Link]
.box {
width: 200px;
height: l 50px;
background-color: #fDfDfD;
border: 2px solid #333;
padding: 20px;
margin: 50px;
Do-While Loop:
J avaScrip1: Loops
lterntion 1
"While Loop:
Ite:mtion,2
Iteration 1 Ite:ration 3
Iteration2
Iteration 3
[Link] 4
Iteration4 Iteration 5
Iteration 5
For Loop:
Ite:mtionl
Ite:ration 2
[Link] 3
Iteration 4
Iteration 5
53. Creating a Java Script program to implement Dialog, Confirm and Message Popup Boxes.
<!DOCTYPE html><html><head>
<title>Popup Boxes Example</title>
</head><body>
<hl>JavaScript Popup Boxes Example</hl>
<button onclick="showAlert()">Show Alert</button>
<button onclick="showConfirm()">Show Confirm</button>
<button onclick="showPrompt()">Show Prompt</button>
<script>
II Function to display an alert box
function showAlert() {
alert("This is an alert box!");
}
54. Implementing a Java Script program to implement onClick and onSubmit event.
<!DOCTYPE html>
<html>
<head>
<title>onClick and onSubmit Events Example</title>
</head>
<body>
<hl>onClickand onSubmit Events Example</hl>
<script>
// Function for onClick event
function changeText() {
var clickExample =
[Link]("clickExample");
[Link] = "Button clicked!";
}
I Click Me I
Submit a Form:
Code:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript 'let' Keyword Example</title>
</head>
<body>
<h1>JavaScript 'let' Keyword Example</h1>
<script>
// Using 'let' to declare
variables let message= "Hello,
World!"; let age= 25;
<script>
// Using 'const' to declare constants
const pi= 3.14159;
const dayslnAWeek = 7;
II Attempting to access the block-scoped constant outside the block (this will result in an
error)
II [Link]("<p>Outside Block:"+ blockScopedConst + "</p>"); // Uncommenting
this line will generate an error
</script>
</body>
</html>
Output
Value of Pi 3.14
Days in a Week: 7
57. Implementing a program in Java Script to create object by using object literal,
creating instance and object constructor.
<!DOCTYPE html><html><head>
<title>JavaScript Object Creation</title>
</head>
<body>
<hl>JavaScript Object Creation</hl>
<h2>Object Literal:</h2>
<script>
// Using Object Literal
var personLiteral =
{ firstName: "John",
lastName: "Doe",
age: 30
};
[Link]("Name: "+ [Link] +" "+ [Link] + "<br>");
[Link]("Age: "+ [Link] + "<br>");
</script>
<h2>Object Instance:</h2>
<script>
// Using Object Instantiation
var personlnstance = new Object();
[Link] = "Jane";
[Link] =
"Smith"; [Link] = 25;
[Link]("Name: "+ [Link] +" "+ [Link] + "<br>");
[Link]("Age: "+ [Link] + "<br>");
</script>
<h2>Object Constructor:</h2>
<script>
// Using Object Constructor
function Person(firstName, lastName, age)
{ [Link] = firstName;
[Link] = lastName;
[Link] = age;
}
var personConstructor = new Person("Bob", "Johnson", 35);
[Link]("Name: "+ [Link] +" "+ [Link] +
"<br>");
[Link]("Age: "+ [Link] + "<br>");
<Iseript></body></html>
Name:Robin
Age:25
<script>
// Original function
function originalFunction(a, b)
{ return a+ b;
}
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
</head>
<body>
<hl>Form Validation Example</hl>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br>
<script>
function validateForm() {
var name= [Link]("name").value;
var email= [Link]("email").value;
var password= [Link]("password").value;
if (!isValidEmail(email)) {
alert("Invalid email address");
return false;
}
if ([Link]< 8) {
alert("Password must be at least 8 characters");
return false;
}
61. Write a program to implement Arrow function with default argument in ES6.
<!DOCTYPE html>
<html>
<head>
<title>Arrow Function with Default Arguments</title>
</head>
<body>
<hl>Arrow Function with Default Arguments</hl>
<script>
// Arrow function with default arguments
const greet= (name = "Guest", time= "morning") =>
{ [Link]('Good ${time}, ${name}!');
};
greet();
greet("Alice", "evening");
Output:
[Link]('Name: ${firstName}');
[Link]('Position: ${position}');
[Link]('Region: ${region}');
[Link]('Nationality: ${nationality}');
Output:
Employee Name: Rajesh Kumar
Role: Software Engineer
City: Mumbai
Country: India
64. Implementing a code in Java Script to implement Spread and rest operator.
canst employees= ["Alice", "Bob", "Charlie"];
canst newEmployees = ["David", ...employees,
"Eva"]; [Link]("New Employees List:",
newEmployees); canst capyOfEmployees =
[...employees];
Output:
["Alice", "Bob", "Charlie", "David"]
Output:
Rajesh Kumar", "Software Engineer", 80000
Output:
Rajesh Kumar", "Software Engineer", 80000
Output:
Length of the string 13
Character at index 7 w
Index of first occurrence of 'o' :4
displayDetails(): string {
return 'Employee Name: ${[Link]}\nRole: ${[Link]}\nSalary:
,${[Link]()}';
}
displayDetails(): string {
return '${[Link](}}\nDepartment: ${[Link]}';
}
}
const managerl = new Manager("Sita Devi", "Engineering Manager", 120000, "Engineering");
[Link]([Link]());
Output:
Rajesh Kumar", "Software Engineer", 80000
Sita Devi", "Engineering Manager", 120000, "Engineering
Output:
Hello, my name is Shivam and I am 30 years old
70. Write a code in typescript that implement decorator and spread operator.
function LoglnstanceCreation(target: Function}
{ const originalConstructor = target;
@LoglnstanceCreation
class Person {
name: string;
age: number;
constructor(name: string, age: number}
{ [Link] = name;
[Link] = age;
}
greet(}: string {
return 'Hello, my name is ${[Link]} and I am ${[Link]} years old.';
}
}
const personl = new Person("Alice", 30};
const person2 = new Person("Bob", 25};
const mergedPerson = {
...person1,
...person 2,
greet(}: string {
return 'Merged Person: ${[Link]} and ${[Link]} years old.';
}
};
[Link](person [Link](} };
[Link]([Link](} };
[Link]([Link](}};
Output:
decorator Alice, bob
fetchData().then(data => {
[Link](data);
}).catch(error => {
[Link](error);
});
Output:
Data fetched successfully
fetchData()
.then(data => processData(data))
.then(processedData => saveData(processedData))
.then(savedData => [Link](savedData))
.catch(error => [Link](error));
Output:
Data fetched successfully
Output:
Slow operation completed
Fast operation completed
75. Create a constant by using define() function with its proper syntax.
// Define a module using AMD
define(['require', 'exports'], function (require: any, exports: any) {
'use strict';
Output: 42
76. Creating PHP script that return any data types whatever you use.
<?php
function getData($type)
{ if ($type=== 'integer')
{
return 42; // Integer
} elseif ($type === 'string')
{ return "Hello, world!";//
String
} elseif ($type=== 'array') {
return ["apple", "banana", "cherry"];// Array
} elseif ($type=== 'object') {
return (object) ['name'=> 'John', 'age'=> 30]; // Object
} elseif ($type=== 'boolean') {
return true;// Boolean
} else {
return null;// Default case for unknown types
}
}
$type= 'object';// Change this value to test different data types
$result= getData($type);
echo "<pre>";
var_dump($result);
echo "</pre>";
?>
Output:
77. Crating a program that implement control flow and decision making statement.
<?php
function controIFlowExample($value) {
if ($value > 10) {
echo "The value is greater than 10.<br>";
} elseif ($value=== 10) {
echo "The value is exactly 10.<br>";
} else {
echo "The value is less than 10.<br>";
}
switch ($value)
{ case 1:
echo "The value is one.<br>";
break;
case 2:
echo "The value is
two.<br>"; break;
case 3:
echo "The value is three.<br>";
break;
default:
echo "The value is neither one, two, nor three.<br>";
break;
}
echo "Looping through numbers:<br>";
for ($i = 1; $i <= 5; $i++) {
echo "Number: $i<br>";
}
echo "Looping with while:<br>";
$i = 6;
while ($i <= 10) {
echo "Number: $i<br>";
$i++;
}
echo "Looping with do-while:<br>";
$i =
11; do
{
echo "Number: $i<br>";
$i++;
} while ($i <= 15);
}
$value= 10;
controlFlowExample($value);
?>
Output:
The value is greater than 10
Output:
Rectangle area (width 5, height 10):50
Rectangle area (width 5, height 20):100
Sum of numbers (1, 2, 3, 4, 5):15
Sum of numbers (10, 20):30
79. Creating program in PHP to store multiple string and concatenate these string and print it.
<?php
$strings= ["Hello" "world" I "this"I "is"I "PHP"]·I
J
Output:
Hello world this is PHP
Output:
["apple", "banana", "cherry"]
81. Write a PHP code to open and close a file in a proper manner.
<?php
$filename= "[Link]";
if ($file) {
fwrite($file, "Hello, world!");
fclose($file);
} else {
echo "Unable to open the file.";
}
?>
Output:
Hello, world
Unable to open the file
Output:
File copied successfully
File deleted successfully
// Create directory
if (mkdir($directory, 0755, true)) {
echo "Directory '$directory' created successfully.<br>";
// Create subdirectory
if (mkdir($subdirectory, 0755, true)) {
echo "Subdirectory '$subdirectory' created successfully.<br>";
} else {
echo "Failed to create subdirectory '$subdirectory'.<br>";
}
} else {
echo "Failed to create directory '$directory'.<br>";
}
if (rmdir($directory)) {
echo "Directory '$directory' deleted successfully.<br>";
} else {
echo "Failed to delete directory '$directory'.<br>";
}
?>
if (file_exists($filepath)) {
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"". basename($filepath). "\"");
header("Expires: O");
header("Cache-Control: must-revalidate");
header("Pragma: public");
header("Content-Length:". filesize($filepath));
flush();
readfile($filepath);
exit;
} else {
echo "The file does not exist.";
}
}
?>
IIPhP file
<?php
session_start(); I I Start the session
Output:
JohnDoe
[Link]@[Link]
Session created
<?php
setcookie("user", "", time() - 3600);
echo "Cookie 'user' deleted.";
?>
Output:
Cookie 'user' set
Cookie 'user' deleted
Output:
JohnDoe
[Link]@[Link]
Session variables are set
Output:
Session variables are destroyed
89. PHP program to store the session data on one page and would be available on
second page.
//store_session.php
<?php
session_start();
$_SESSION["message"] = "Hello from the first page.";
header("Location: display_session.php");
exit();
?>
//display_session.php
<?php
session_start();
if (isset($_SESSION["message"]))
{ echo $_SESSION[" message"];
} else {
echo "No session data found.";
}
?>
Output: