Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

PART - A

1. Answer All:
a. What is an Anchor tag in HIML?
Ans: - An anchor tag in HTML is a markup element used to create a
hyperlink to another webpage or a specific location within the same
webpage.
b. How is Cell Padding different from Cell Spacing?
Ans: - Cell padding refers to the space between the cell content and the
cell border in a table, while cell spacing refers to the space between
adjacent cells in a table.
c. What is HTML frameset?
Ans: - HTML frameset is a deprecated HTML element that was used to
divide a web page into multiple sections or frames, each with its own
HTML document.
d. What is the difference between class selector and id selector in CSS?
Ans: - Class selectors are used to apply styles to multiple elements with
the same class attribute, while ID selectors are used to apply styles to a
single element with a unique ID attribute.
e. What is inline, embedded and external Style Sheet.
Ans: - Inline, embedded, and external style sheets are different ways to
define styles for HTML elements in web pages. Inline styles are defined
within the HTML element using the "style" attribute. Embedded styles are
defined in the head section of the HTML document using the "style" tag.
External styles are defined in a separate CSS file and linked to the HTML
document using the "link" tag.
f. What are dialog boxes in JavaScript?
ANS: - Dialog boxes in JavaScript are modal windows that display
messages or prompt users for input. They include alert boxes,
confirmation boxes, and prompt boxes.
g. What is the use of "isset" in PHP?
Ans: - "isset" is a function in PHP used to check if a variable is set and not
null. It returns true if the variable is set and not null, and false otherwise.
h. What are different output functions in PHP?.
Ans: - Some common output functions in PHP are "echo", "print", and
"print". "Echo" and "print" are used to output strings, while "print" is used to
format and output strings according to a specified format.
i. What is the difference between $ GET and $ POST in PHP?
Ans: - $GET and $POST are both super global arrays in PHP used to
retrieve data from HTML forms. $GET retrieves data using the GET
method, which appends form data to the URL. $POST retrieves data using
the POST method, which sends form data in the request body.
j. What is the difference between array slice and array _combine in PHP?
Ans: - "array_slice" is a function in PHP used to extract a slice of an array.
It takes an array and two indices as parameters and returns a new array
containing the elements between the two indices. "array_combine" is a
function used to create an associative array from two arrays, where one
array contains the keys and the other contains the values.

PART - B
2. Write HTML and Java Script code to design a registration page and validate
all the fields using Java Script.
ANS: -

This code creates a simple registration form with fields for Name, Email, Phone
Number, Password, and Confirm Password. The JavaScript code includes a
function to validate the form fields and ensure that all required fields are filled
out, the password matches the confirm password, and the phone number and
email address are in valid formats. The function is triggered when the Submit
button is clicked.
3. What is Event? Explain some keyboard events in Java Script by giving a
suitable example.
Ans:- In JavaScript, an event is an action that occurs as a result of user
interaction with a webpage or browser. There are several keyboard events
that can be used in JavaScript, including:
 keydown: triggered when a key is pressed down
 keyup: triggered when a key is released
 keypress: triggered when a key is pressed down and released
4. Write code to explain the use of inline, embedded and external Style Sheet.
Ans :- Inline Styles:
Inline styles are styles that are directly applied to an HTML element using the
"style" attribute. The following code example demonstrates how to use inline
styles to set the background color of a paragraph element to blue:

<p style="background-color: blue;">This is a paragraph with a blue


background.</p>
Embedded Styles:
Embedded styles are styles that are included within the HTML document
using the <style> tag. The following code example demonstrates how to use
embedded styles to set the font size of all paragraph elements to 16px:
<head>
<style>
p { font-size: 16px; }
</style>
</head>
<body>
<p>This is a paragraph with a font size of 16px.</p>
<p>This is another paragraph with a font size of 16px.</p>
</body>
External Styles:
External styles are styles that are defined in a separate CSS file and linked to the
HTML document using the <link> tag. The following code example demonstrates
how to use an external stylesheet to set the font color of all heading elements to
red:
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head> <body> <h1>This is a heading with a red font color.</h1>
<h2>This is another heading with a red font color.</h2>
</body>
5. What is Session? Write a Program in PHP to explain the create, change and
destroy of Session.
Ans :- In PHP, a session is a way to store information across multiple
requests. Sessions are commonly used to keep track of user data, such as
login status or shopping cart contents.
Creating a session:
To create a session in PHP, use the "session_start()" function at the
beginning of your code:
<?php session_start(); ?>

Changing session data: To change session data, simply assign a new value to a
session variable:

<?php $_SESSION['username'] = 'John'; ?>

Destroying a session: To destroy a session and remove all session data, use
the "session_destroy()" function:

<?php session_destroy(); ?>


6. Write PHP code to design a Login page and validate the user Id and
password by connecting to database.
Ans : -
7. What is function? Write PHP code to explain "pass by value" and "pass by
reference" in PHP.
Ans :- Functions in PHP:
A function is a block of code that performs a specific task. Functions can
accept input values, called parameters, and can return a value.

Pass by value:
In PHP, variables are typically passed to functions by value. This means that
the function receives a copy of the variable's value, rather than a reference to
the variable itself. Changes made to the variable within the function will not
affect the original variable outside of the function.

Example:
<?php
function addOne($x) {
$x = $x + 1;
return $x;
}
$a = 5;
echo addOne($a); // Output: 6
echo $a; // Output: 5
?>
Ecample 2
<?php
function calculate(&$a1){
$a1++;
}
$a1=5;
echo "This is the value of a1 variable before the function
call :: ";
echo $a1;
echo "<br>";
echo "This is the value of a1 variable after the function
call :: ";
calculate($a1);
echo $a1;
?>
8. Write short notes on any Two:-

a) PHP Datatype:
PHP data types are used to hold different types of data or values. PHP supports 8
primitive data types that can be categorized further in 3 types:

1. Scalar Types (predefined)


2. Compound Types (user-defined)
3. Special Types

PHP Data Types: Scalar Types


It holds only single value. There are 4 scalar data types in PHP.

1. boolean
2. integer
3. float
4. string
PHP Data Types: Compound Types
It can hold multiple values. There are 2 compound data types in PHP.

1. array
2. object

PHP Data Types: Special Types


There are 2 special data types in PHP.

1. resource
2. NULL

b) Java Script Events:-


JavaScript events are actions or occurrences that
happen in the web browser, such as a user clicking a button, scrolling the
page, or submitting a form. In JavaScript, we can listen for these events and
trigger specific actions in response.

Here are some common JavaScript events:


Click - This event is fired when a user clicks on an element, such as a button
or a link.
Mouseover - This event is fired when a user moves their mouse over an
element.
Keydown - This event is fired when a user presses a key on their keyboard.
Load - This event is fired when a web page finishes loading.
Submit - This event is fired when a user submits a form.

c) HTML Form Elements

An HTML form is a section of a document which contains controls such as text


fields, password fields, checkboxes, radio buttons, submit button, menus etc.

An HTML form facilitates the user to enter data that is to be sent to the server
for processing such as name, email address, password, phone number, etc. .

d) HTML DOM
It is a programming interface for web documents that allows
JavaScript to manipulate the HTML and CSS content of a
webpage. The DOM represents the structure of an HTML
document as a tree-like hierarchy of nodes, with each node
representing an HTML element, attribute, or text content.
1. Accessing HTML elements - We can use methods like getElementById() ,
getElementsByClassName() , and getElementsByTagName() to access specific HTML
elements within the DOM.

2. Manipulating HTML attributes - We can use methods like getAttribute() and


setAttribute() to get and set HTML attributes of elements.

You might also like