0% found this document useful (0 votes)
17 views29 pages

PHP ### A) What Is An Indexed Array?

Uploaded by

anishchavan1111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views29 pages

PHP ### A) What Is An Indexed Array?

Uploaded by

anishchavan1111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Php print_r($ages);

### a) What is an indexed array? Output:

An **indexed array** is a type of array in PHP Array


where each element is stored with a numeric
index, starting from 0 by default. It is the most (
common type of array, and the indices are [Doe] => 29
automatically assigned by PHP if not specified.
[John] => 25
Example:
[Jane] => 22
```php
)
$fruits = ["apple", "banana", "orange"];
### d) What is the use of Sticky form in PHP?
echo $fruits[0]; // Output: apple
A **sticky form** refers to a technique in PHP
### b) What is the difference between to preserve the user input values in a form
"echo" and "print"? after submission. This is particularly useful
- **echo**: It is a language construct used to when a user has entered incorrect data and
output one or more strings. It has no return the form needs to be displayed again with the
value and can take multiple parameters. previously entered values retained.

- Example: `echo "Hello", " World";` To implement sticky forms, PHP uses the
`$_POST` or `$_GET` superglobal to re-
- **print**: It is also a language construct, but populate form fields with the data from the
it can only output a single string and returns a previous submission.
value (1), which makes it useful in
expressions. Example:

- Example: `print "Hello World";` ```php

### c) Explain `krsort()` function in PHP. <input type="text" name="username"


value="<?php echo isset($_POST['username'])
The `krsort()` function in PHP is used to sort ? $_POST['username'] : ''; ?>">
an **associative array** in reverse order
according to the keys. The order of the ### e) Explain `setcookie()` function in PHP.
elements is reversed, but the keys remain The `setcookie()` function in PHP is used to
associated with their respective values. send a cookie to the client’s browser. Cookies
Example: are small pieces of data stored on the client-
side and can be used to remember user
```php preferences or sessions.

$ages = ["John" => 25, "Jane" => 22, "Doe" => Syntax:
29];
```php
krsort($ages);
setcookie("user", "John", time() + 3600); // expression that evaluates a condition and
Expires in 1 hour returns one value if true and another value if
false.
Here, "user" is the cookie name, "John" is the
value, and `time() + 3600` sets the expiration Syntax:
time to 1 hour.
```php
### f) What is `$_SESSION` in PHP?
(condition) ? value_if_true : value_if_false;
`$_SESSION` is a superglobal array in PHP that
is used to store session variables. Session Example:
variables are stored on the server and can be ```php
used to maintain state across multiple pages
during a user’s visit to a website (i.e., session $age = 20;
persistence).
echo ($age >= 18) ? "Adult" : "Minor"; //
Example: Output: Adult

```php ### i) Explain `array_slice()` function in PHP.

session_start(); The `array_slice()` function is used to extract a


portion of an array. It returns a new array
$_SESSION["username"] = "JohnDoe"; containing a slice of the original array starting
echo $_SESSION["username"]; // Output: from a specified offset.
JohnDoe Syntax:
### g) Explain `var_dump()` function in PHP. ```php
The `var_dump()` function in PHP is used to array_slice($array, $offset, $length,
display structured information (type and $preserve_keys);
value) about one or more variables. It shows
the type and the length of arrays or strings, ```
and it’s helpful for debugging.
- `$array`: The input array.
Example:
- `$offset`: The starting index.
```php
- `$length`: (optional) The number of
$var = array(1, 2, 3); elements to extract.

var_dump($var); - `$preserve_keys`: (optional) Whether to


preserve the array keys.
Output:
Example:
array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
```php
### h) What is the Ternary operator in PHP?
$arr = [1, 2, 3, 4, 5];
The **ternary operator** is a shorthand for
the `if-else` statement. It is a conditional $slice = array_slice($arr, 2, 2); // Returns [3, 4]
print_r($slice); ### a) List the types of array in PHP.

### j) Explain `mysqli_connect()` in PHP. In PHP, arrays can be categorized into **three
types**:
The `mysqli_connect()` function is used to
open a connection to a MySQL database 1. **Indexed Array**: An array where each
server. It returns a connection object that can element is assigned a numeric index (starting
be used for querying the database. from 0 by default).

Syntax: - Example: `$fruits = ["Apple", "Banana",


"Orange"];`
```php
2. **Associative Array**: An array where each
$connection = mysqli_connect($host, element is assigned a custom key (string or
$username, $password, $dbname, $port, integer).
$socket);
- Example: `$ages = ["John" => 25, "Jane" =>
- `$host`: The hostname or IP address of the 22];`
database server.
3. **Multidimensional Array**: An array that
- `$username`: The username to access the contains other arrays as its elements (arrays
database. within arrays).
- `$password`: The password for the - Example: `$contacts = [["name" => "John",
username. "phone" => "1234"], ["name" => "Jane",
- `$dbname`: The database name. "phone" => "5678"]];`

- `$port`: (optional) The port number. ### b) What are different arithmetic
operators in PHP?
- `$socket`: (optional) The socket or named
pipe. PHP supports the following **arithmetic
operators**:
Example:
1. **Addition (`+`)**: Adds two numbers.
```php
- Example: `$sum = 5 + 3;`
$connection = mysqli_connect("localhost",
"root", "", "test_db"); 2. **Subtraction (`-`)**: Subtracts one
number from another.
if (!$connection) {
- Example: `$difference = 5 - 3;`
die("Connection failed: " .
mysqli_connect_error()); 3. **Multiplication (`*`)**: Multiplies two
numbers.
}
- Example: `$product = 5 * 3;`
Here are the answers to your PHP-related
questions: 4. **Division (`/`)**: Divides one number by
another.

- Example: `$quotient = 6 / 3;`


- You cannot create an instance of an abstract
class, but you can create instances of classes
5. **Modulus (`%`)**: Returns the remainder that extend it.
of division.
### d) Define sticky form.
- Example: `$remainder = 5 % 3;`
A **sticky form** in PHP refers to a form
6. **Exponentiation (`**`)**: Raises one where, after submission, the form fields retain
number to the power of another. the values previously entered by the user,
- Example: `$power = 2 ** 3;` (result is 8) especially after validation errors. This allows
users to correct their mistakes without re-
### c) What is an abstract class in PHP? entering all the data.

An **abstract class** in PHP is a class that To implement sticky forms, you can use PHP's
cannot be instantiated directly. It is meant to `$_POST` superglobal to preserve the form
be inherited by other classes, which must data across page reloads.
implement its abstract methods. Abstract
classes can contain both abstract methods Example:
(without implementation) and concrete ```php
methods (with implementation).
<input type="text" name="username"
- **Syntax**: value="<?php echo isset($_POST['username'])
```php ? $_POST['username'] : ''; ?>">

abstract class Shape { ### e) What is validation?

abstract public function area(); // Abstract **Validation** refers to the process of


method checking the user input in a form to ensure it
meets certain criteria or rules before
public function display() { // Concrete processing it. Common types of validation
method include checking for required fields, valid
email addresses, valid phone numbers, and
echo "Displaying shape!";
correct data types.
}

}
Validation can be done **on the client-side**
class Circle extends Shape { (using JavaScript) or **server-side** (using
PHP). Server-side validation is more secure as
public function area() { it ensures data integrity regardless of client
behavior.
return 3.14 * $this->radius * $this-
>radius; // Implement abstract method

} Example of server-side validation in PHP:

} ```php

if (empty($_POST["email"])) {
echo "Email is required"; 2. **PostgreSQL**: Supported through the
`pg_connect()` and `PDO_PGSQL` extensions.
}
3. **SQLite**: Supported via the `SQLite3`
### f) What is the use of `array_slice()` in and `PDO_SQLITE` extensions.
PHP?
4. **Oracle**: Supported through the `oci8`
The **`array_slice()`** function in PHP is used extension.
to extract a portion of an array. It returns a
new array containing a subset of the original 5. **MSSQL (Microsoft SQL Server)**:
array, starting from a specified offset and Supported via the `sqlsrv` extension.
optionally limiting the number of elements.
6. **MariaDB**: Supported using the same
**Syntax**: extensions as MySQL (`mysqli`,
`PDO_MySQL`).
```php
7. **MongoDB**: Supported via the `mongo`
array_slice($array, $offset, $length, or `mongodb` extension.
$preserve_keys);
8. **Other databases**: PHP also supports
- `$array`: The input array. many other databases through PDO (PHP Data
- `$offset`: The starting index. Objects) and specific database extensions.

- `$length`: (optional) The number of ### h) What is the use of session?


elements to extract. A **session** in PHP is used to store user-
- `$preserve_keys`: (optional) Whether to specific data across multiple pages during a
preserve the original array keys. user's visit to a website. It allows for stateful
interaction with the user, such as keeping
**Example**: track of login credentials, shopping cart items,
or preferences.
```php
- **Session variables** are stored on the
$array = [1, 2, 3, 4, 5];
server and are accessed via the `$_SESSION`
$slice = array_slice($array, 2, 2); // Result: [3, superglobal.
4]
- Sessions are uniquely identified by a session
print_r($slice); ID, usually stored in a cookie.

### g) What are the databases supported by **Example**:


PHP?
```php
PHP supports a wide variety of databases.
session_start();
Some of the most commonly used ones are:
$_SESSION['username'] = 'JohnDoe';
1. **MySQL**: PHP has extensive support for
MySQL through the `mysqli` and echo $_SESSION['username']; // Output:
`PDO_MySQL` extensions. JohnDoe
Sessions are automatically destroyed when }
the user closes the browser, or they can be
explicitly destroyed using `session_destroy()`. echo $i . " ";

### i) Which attribute is used for multiple }


selections in the `<select>` tag? // Output: 0 1 2 3 4
The `multiple` attribute is used in the Q2) a) What are the features of PHP?
`<select>` tag to allow multiple selections in a
drop-down list. When this attribute is added, PHP (Hypertext Preprocessor) is a powerful,
the user can select more than one option. open-source server-side scripting language
that is widely used for web development.
**Example**: Some key features of PHP include:
```html 1. **Server-Side Scripting**: PHP is primarily
<select name="fruits[]" multiple> used for server-side scripting. It can generate
dynamic web pages, handle forms, interact
<option value="apple">Apple</option> with databases, and create complex web
applications.
<option value="banana">Banana</option>
2. **Cross-Platform**: PHP is platform-
<option value="orange">Orange</option> independent, which means it can run on
</select> various operating systems, such as Windows,
Linux, macOS, etc.
The `multiple` attribute enables multiple
selections, and the selected values can be 3. **Open Source**: PHP is open-source and
accessed as an array in PHP free to use, with a large community of
(`$_POST['fruits[]']`). developers continually improving it.

### j) What is the purpose of the `break` 4. **Database Integration**: PHP has built-in
statement? support for connecting and interacting with
multiple databases such as MySQL,
The `break` statement is used to **exit** PostgreSQL, SQLite, and others.
from a loop (such as `for`, `while`, or
`foreach`) or a `switch` statement. It stops the 5. **Supports Sessions and Cookies**: PHP
loop or switch execution and transfers control allows managing sessions and cookies,
to the next statement following the loop or enabling personalized user experiences and
switch. state management.

**Example**: 6. **Simple and Easy to Learn**: PHP is


beginner-friendly, with simple syntax and easy
```php integration into HTML.

for ($i = 0; $i < 10; $i++) { 7. **Flexible and Extensible**: PHP supports
various web frameworks and libraries (like
if ($i == 5) {
Laravel, Symfony) and can be extended with
break; // Exit the loop when $i equals 5 custom functions, classes, and modules.
- The `sumOfDigits()` function loops through
the number by repeatedly extracting the last
8. **Security**: PHP offers various features digit using the modulus operator (`% 10`) and
for improving security, including escaping adding it to the sum.
data for SQL queries, protecting against XSS
and CSRF attacks, and more. - The number is reduced by dividing it by 10
on each iteration (`$num = (int)($num / 10)`).
### b) Write a PHP script to find the sum of
digits of a number. - Finally, it prints the sum of the digits.

You can find the sum of digits of a number by ### c) Explain `for` loop and `foreach` loop
converting the number to a string and then with examples.
iterating through each digit, adding them up.
Here's a PHP script for that: #### 1. **`for` Loop**:

```php A `for` loop is used when you know in advance


how many times you want to iterate through
<?php a block of code. It consists of three parts:

// Function to calculate the sum of digits - **Initialization**: Initializing the loop


variable.
function sumOfDigits($num) {
- **Condition**: The loop will continue
$sum = 0; running as long as this condition evaluates to
// Iterate through each digit true.

while ($num > 0) { - **Increment/Decrement**: Modifying the


loop variable on each iteration.
$sum += $num % 10; // Get the last digit
**Example of `for` loop**:
$num = (int)($num / 10); // Remove the
last digit ```php

} <?php

return $sum; // Print numbers from 1 to 5 using a for loop

} for ($i = 1; $i <= 5; $i++) {

// Example usage echo $i . " ";

$number = 12345; }

echo "The sum of digits of $number is: " . ?>


sumOfDigits($number); ```
?> **Output**: `1 2 3 4 5`
**Explanation**:

**Explanation**:
- The loop starts with `$i = 1`, and continues ?>
until `$i` reaches 5.
```
- In each iteration, the value of `$i` is printed
and incremented by 1. **Output**: `John is 25 years old. Jane is 22
years old. Doe is 29 years old.`
#### 2. **`foreach` Loop**:

The `foreach` loop is used to iterate over


arrays, where each element of the array is **Explanation**:
automatically assigned to a variable. It is - In the first example, `$fruit` takes each
particularly useful when you need to work element from the `$fruits` array.
with arrays, especially associative arrays.
- In the second example, `$name` and `$age`
**Example of `foreach` loop**: represent the key-value pairs of the
```php associative array

<?php ### d) Explain Cookies in PHP.

// Iterate over an indexed array A **cookie** in PHP is a small piece of data


that is stored on the client-side (in the user's
$fruits = ["apple", "banana", "orange"]; browser). Cookies are used to store user
preferences or other information that can be
foreach ($fruits as $fruit) { accessed across different pages on a website.
echo $fruit . " "; Cookies can be set by the server, and they are
automatically sent back to the server with
} each subsequent HTTP request.

?> #### How to set a cookie in PHP:

``` You can set a cookie using the `setcookie()`


function, which must be called before any
**Output**: `apple banana orange`
output is sent to the browser (since it sends
**Example of `foreach` with an associative HTTP headers).
array**:
**Syntax**:
```php
```php
<?php
setcookie(name, value, expire, path, domain,
// Iterate over an associative array secure, httponly);

$ages = ["John" => 25, "Jane" => 22, "Doe" => - `name`: The name of the cookie.
29];
- `value`: The value stored in the cookie.
foreach ($ages as $name => $age) {
- `expire`: The time when the cookie will
echo "$name is $age years old. "; expire (in Unix timestamp format).

}
- `path`: The path where the cookie is ### e) Explain any two Built-in Array
available (optional). functions in PHP.

- `domain`: The domain that the cookie is PHP provides many built-in functions for
available to (optional). working with arrays. Here are explanations for
two commonly used array functions:
- `secure`: If true, the cookie is only sent over
secure HTTPS connections. #### 1. **`array_merge()`**:

- `httponly`: If true, the cookie can only be The `array_merge()` function merges two or
accessed by the HTTP protocol and not by more arrays into a single array. If the arrays
JavaScript. have string keys, the values from later arrays
will overwrite the values from earlier arrays
**Example**: with the same key. If the arrays have numeric
```php keys, the values are appended.

<?php **Example**:

// Set a cookie named "user" with the value ```php


"JohnDoe" that expires in 1 hour <?php
setcookie("user", "JohnDoe", time() + 3600, $array1 = ["apple", "banana"];
"/");
$array2 = ["orange", "grape"];
// Check if the cookie is set
$mergedArray = array_merge($array1,
if (isset($_COOKIE["user"])) { $array2);
echo "Hello " . $_COOKIE["user"]; print_r($mergedArray);
} else { ?>
echo "Cookie 'user' is not set!"; ```
} **Output**:
?> ```
**Explanation**: Array
- The `setcookie()` function is used to store a (
cookie that will expire in 1 hour.
[0] => apple
- The `$_COOKIE` superglobal is used to
access the cookie value. [1] => banana

- If the cookie is set, it will display "Hello [2] => orange


JohnDoe"; otherwise, it will show the
message "Cookie 'user' is not set". [3] => grape

)
Q2) a) Explain multidimensional array in PHP ```php
with example.
<?php
A **multidimensional array** in PHP is an
array that contains one or more arrays as its // A 3D array representing multiple matrices
elements. It is essentially an array of arrays, $threeDArray = [
allowing you to store data in a table-like
structure. You can create arrays with any [
number of dimensions.
[1, 2],
#### Example of a 2D (two-dimensional)
[3, 4]
array:
],
```php
[
<?php
[5, 6],
// A 2D array representing a matrix (rows and
columns) [7, 8]
$matrix = [ ]
[1, 2, 3], ];
[4, 5, 6], // Accessing an element in the 3D array
(matrix 1, row 0, column 1)
[7, 8, 9]
echo $threeDArray[1][0][1]; // Output: 6
];
?>
// Accessing an element in the 2D array (row
1, column 2) ### b) Write a PHP Program to check
whether the given year is a leap year or not
echo $matrix[1][2]; // Output: 6
(use if-else).
?>
A **leap year** is a year that is divisible by 4,
#### Explanation: but not divisible by 100 unless it is also
divisible by 400. Here's a PHP program to
- `$matrix` is a 2D array where each element check if a given year is a leap year:
is itself an array.
```php
- You can access the elements by specifying
both the row and the column index. <?php

- The first index refers to the row, and the // Function to check if the year is a leap year
second index refers to the column.
function isLeapYear($year) {
#### Example of a 3D (three-dimensional)
if (($year % 4 == 0 && $year % 100 != 0) ||
array:
($year % 400 == 0)) {
return true; const PI = 3.14159; // Defining a constant
in the interface
} else {
public function area(); // Method to
return false; calculate the area
} public function volume(); // Method to
} calculate the volume

// Example usage }

$year = 2024; // Defining the Cylinder class that implements


the Shape interface
if (isLeapYear($year)) {
class Cylinder implements Shape {
echo "$year is a Leap Year.";
private $radius;
} else {
private $height;
echo "$year is not a Leap Year.";
// Constructor to initialize the radius and
} height of the cylinder

?> public function __construct($radius,


$height) {
#### Explanation:
$this->radius = $radius;
- The function `isLeapYear()` uses the **if-
else** condition to check if the year is $this->height = $height;
divisible by 4 but not by 100 unless it is
divisible by 400. }

- The result is displayed using `echo`. // Implementing the area() method to


calculate the area of the cylinder
### c) Write a PHP script to define an
interface which has methods `area()` and public function area() {
`volume()`. Define constant `PI`. Create a return 2 * Shape::PI * $this->radius *
class `Cylinder` which implements this ($this->radius + $this->height);
interface and calculates area and volume.
}
#### Interface and Class Implementation:
// Implementing the volume() method to
```php calculate the volume of the cylinder
<?php public function volume() {
// Defining an interface with methods area() return Shape::PI * $this->radius * $this-
and volume() >radius * $this->height;
interface Shape { }
} 2. **`strtoupper()`**: Converts all characters
of a string to uppercase.
// Creating an instance of the Cylinder class
- Example: `echo strtoupper("hello");` //
$cylinder = new Cylinder(5, 10); Output: HELLO
// Calculating and displaying the area and 3. **`strtolower()`**: Converts all characters
volume of a string to lowercase.
echo "Area of the cylinder: " . $cylinder- - Example: `echo strtolower("HELLO");` //
>area() . "<br>"; Output: hello
echo "Volume of the cylinder: " . $cylinder- 4. **`substr()`**: Extracts a portion of a
>volume(); string.
?> - Example: `echo substr("Hello World", 0,
#### Explanation: 5);` // Output: Hello

- The `Shape` interface defines the `area()` 5. **`strpos()`**: Finds the position of the first
and `volume()` methods and a constant `PI`. occurrence of a substring in a string.

- The `Cylinder` class implements the `Shape` - Example: `echo strpos("Hello World",
interface and provides concrete "World");` // Output: 6
implementations for the `area()` and 6. **`str_replace()`**: Replaces all
`volume()` methods. occurrences of a substring within a string.
- The `area()` method calculates the surface - Example: `echo str_replace("world", "PHP",
area of the cylinder, and the `volume()` "Hello world!");` // Output: Hello PHP!
method calculates the volume.
7. **`trim()`**: Removes whitespace (or other
- The constant `PI` is accessed using characters) from both ends of a string.
`Shape::PI`.
- Example: `echo trim(" Hello ");` // Output:
### d) What are the built-in functions of Hello
strings in PHP?
8. **`explode()`**: Splits a string into an array
PHP provides a variety of built-in string by a delimiter.
functions that allow manipulation and
processing of string data. Here are some - Example: `print_r(explode(",",
commonly used string functions: "apple,banana,orange"));`

1. **`strlen()`**: Returns the length of a - Output: `Array ( [0] => apple [1] => banana
string. [2] => orange )`

- Example: `echo strlen("Hello");` // Output: 9. **`implode()`**: Joins an array into a single


5 string using a delimiter.

- Example: `echo implode("-", ["2024", "11",


"10"]);` // Output: 2024-11-10
### e) Write a PHP program to reverse an #### Explanation:
array.
- The `array_reverse()` function takes an array
To reverse an array in PHP, you can use the and returns a new array with the elements in
built-in `array_reverse()` function, which reverse order.
returns the reversed version of the array.
- The `print_r()` function is used to display the
#### Example program to reverse an array: reversed array.

```php These answers cover key PHP concepts such


as multidimensional arrays, conditionals,
<?php interfaces, string functions, and array
// Function to reverse an array manipulation. Let me know if you need
further clarification on any topic.
function reverseArray($arr) {
Here are the answers to the questions you
return array_reverse($arr); // Reverse the asked:
array

}
Q3) a) Write a PHP script to display the table
// Example array of a number.

$array = [1, 2, 3, 4, 5]; A simple PHP script can display the


multiplication table for a given number.
// Reversing the array
Here’s how you can do it:
$reversedArray = reverseArray($array);
```php
// Printing the reversed array
<?php
print_r($reversedArray);
// Get the number from the user or set it
?> directly

#### Output: $number = 5; // You can change this to any


number or accept from user input using
Array $_GET or $_POST

( // Display the table of the number

[0] => 5 echo "Multiplication table of $number:<br>";

[1] => 4 for ($i = 1; $i <= 10; $i++) {

[2] => 3 echo "$number x $i = " . ($number * $i) .


"<br>";
[3] => 2
#### Explanation:
[4] => 1

)
- The `$number` is set to 5 in this case, but #### 2. **`str_replace()`**:
you can modify it to accept input from the
user if required. The `str_replace()` function replaces all
occurrences of a substring within a string.
- The `for` loop iterates from 1 to 10 and
prints the multiplication result for the given
number. **Example**:
**Output for $number = 5**: ```php
Multiplication table of 5: <?php
5x1=5 $str = "I love programming!";
5 x 2 = 10 $newStr = str_replace("programming", "PHP",
5 x 3 = 15 $str);

5 x 10 = 50 echo $newStr; // Output: I love PHP!

### b) Write any two Built-in functions of ?>


String with example. **Explanation**:
PHP provides several built-in functions to - The `str_replace()` function replaces the
manipulate strings. Here are two commonly word "programming" with "PHP" in the string
used functions: `$str` and outputs the modified string.
#### 1. **`strlen()`**: ### c) Write a code in PHP which accepts two
The `strlen()` function returns the length of a strings from user and displays them after
string. concatenation.

**Example**: Here’s a PHP code that accepts two strings


from the user using a simple HTML form and
```php then concatenates and displays them:

<?php #### PHP Code (with HTML form for user


input):
$str = "Hello, World!";
```php
echo "The length of the string is: " .
strlen($str); // Output: 13 <?php

?> if ($_SERVER["REQUEST_METHOD"] ==
"POST") {
**Explanation**:
// Get the strings from the user input
- The `strlen()` function calculates and returns
the number of characters in the string `$str`. $string1 = $_POST['string1'];

$string2 = $_POST['string2'];
// Concatenate the strings For example, the factorial of 5 is `5! = 5 × 4 × 3
× 2 × 1 = 120`.
$result = $string1 . " " . $string2;
Here’s a PHP program to calculate the
factorial:
// Display the concatenated result ```php
echo "Concatenated String: " . $result; <?php
} // Function to calculate factorial
?> function factorial($n) {
<!-- HTML form to accept two strings from the if ($n == 0 || $n == 1) {
user -->
return 1; // Factorial of 0 and 1 is 1
<form method="POST">
} else {
String 1: <input type="text" name="string1"
required><br><br> return $n * factorial($n - 1); // Recursive
call
String 2: <input type="text" name="string2"
required><br><br> }

<input type="submit" }
value="Concatenate">
// Example usage
</form>
$number = 5; // Change this number to
#### Explanation: calculate its factorial

- This script first checks if the form has been echo "The factorial of $number is: " .
submitted using the factorial($number);
`$_SERVER["REQUEST_METHOD"] == "POST"`.
?>
- It then collects the two strings (`string1` and
`string2`) from the user input, concatenates #### Explanation:
them with a space in between, and displays - The function `factorial()` calculates the
the result. factorial using recursion. It multiplies the
**Example Output**: number `n` by the factorial of `n - 1` until it
reaches 1.
Concatenated String: Hello World
- The result is printed after the function is
### d) Write a PHP program to calculate the called with the desired number.
factorial of a number.
**Output for $number = 5**:

The factorial of 5 is: 120


The factorial of a number `n` is the product of
all positive integers less than or equal to `n`.
### e) Write a PHP script to check whether a #### a) What is a variable in PHP? Explain its
number is prime or not. scope with example.

A **prime number** is a number greater A **variable** in PHP is a container used to


than 1 that has no positive divisors other than store data, such as strings, numbers, or
1 and itself. Here's how you can check if a arrays. Variables in PHP start with a dollar sign
number is prime: (`$`) followed by the variable name.

```php - **Variable syntax**: `$variable_name =


value;`
<?php
#### **Scope of a Variable:**
// Function to check if a number is prime
The **scope** of a variable defines where
function isPrime($num) { the variable can be accessed within a script.
if ($num <= 1) { PHP supports several types of scopes:

return false; // Numbers less than or 1. **Global Scope**: A variable declared


equal to 1 are not prime outside of all functions or classes has a global
scope, and it can be accessed anywhere in the
} script after it has been declared.

for ($i = 2; $i <= sqrt($num); $i++) { **Example**:

if ($num % $i == 0) { ```php

return false; // Number is divisible by $x = 10; // Global variable


$i, so it's not prime
function myFunction() {
}
global $x; // Access global variable
}
echo $x;
return true; // The number is prime
}
}
myFunction(); // Output: 10
// Example usage
2. **Local Scope**: A variable declared within
$number = 29; // You can change this number a function or method is local to that function
to check other numbers and cannot be accessed outside of it.

if (isPrime($number)) { **Example**:

echo "$number is a prime number."; ```php

} else { function myFunction() {

echo "$number is not a prime number."; $y = 5; // Local variable

} echo $y;
} }

myFunction(); // Output: 5 // Output: 1 2 3 4 5

// echo $y; // Error: Undefined variable 2. **`foreach` Loop**:

3. **Static Scope**: A variable declared as - The `foreach` loop is specifically designed


`static` inside a function retains its value for iterating over arrays. It simplifies the
across function calls. iteration process when you want to access
array elements directly without worrying
**Example**: about their index.
```php - Syntax: `foreach ($array as $value)`
function counter() { **Example**:
static $count = 0; ```php
$count++; $fruits = ["apple", "banana", "cherry"];
echo $count; foreach ($fruits as $fruit) {
} echo $fruit . " ";
counter(); // Output: 1 }
counter(); // Output: 2 // Output: apple banana cherry
#### b) What is the difference between `for` **Key Differences**:
and `foreach` in PHP?
- **`for`**: Used for arrays where you need to
The main difference between `for` and manage the index or for fixed iterations.
`foreach` loops in PHP is how they are used
and their specific use cases: - **`foreach`**: Easier to use for iterating
over arrays without needing to manually
1. **`for` Loop**: manage the index.
- The `for` loop is typically used when you #### c) Write a PHP Program to display the
know the number of iterations in advance reverse of a string.
(e.g., when iterating over a range of numbers
or a fixed-size array). You can reverse a string in PHP using the built-
in function `strrev()`. Here's a simple PHP
- Syntax: `for(initialization; condition; program to reverse a string:
increment)`
```php
**Example**:
<?php
```php
// Input string
for ($i = 1; $i <= 5; $i++) {
$string = "Hello World!";
echo $i . " ";
// Reverse the string - **httponly**: Whether the cookie is
accessible only via the HTTP protocol (not
$reversedString = strrev($string); JavaScript).
// Display the reversed string **Example**:
echo "Reversed string: " . $reversedString; ```php
?> <?php
**Explanation**: // Set a cookie that expires in 1 hour
- The `strrev()` function reverses the string setcookie("user", "JohnDoe", time() + 3600,
and returns the reversed version. "/");
- The result is displayed using `echo`. // Check if the cookie is set
**Output**: if (isset($_COOKIE["user"])) {
Reversed string: !dlroW olleH echo "Welcome " . $_COOKIE["user"];
#### d) How to create cookies? Give an } else {
example.
echo "Cookie 'user' is not set!";
Cookies in PHP are created using the
`setcookie()` function. A cookie is a small }
piece of data that is stored on the client’s
browser. It can store values like user ?>
preferences, session identifiers, etc. **Explanation**:
**Syntax**: - The `setcookie()` function sets a cookie
```php named `user` with the value `JohnDoe`. The
cookie will expire in one hour (3600 seconds).
setcookie(name, value, expire, path, domain,
secure, httponly); - The cookie can then be accessed using
`$_COOKIE["user"]`.
- **name**: The name of the cookie.
**Output (if cookie is set)**:
- **value**: The value of the cookie.
Welcome JohnDoe
- **expire**: The expiration time (in Unix
timestamp format). #### e) Explain passing values by reference
with an example.
- **path**: The path where the cookie is
available. In PHP, values can be passed by reference
using the **`&`** symbol. When passing by
- **domain**: The domain to which the reference, changes made to the parameter
cookie is available. inside the function will affect the original
variable outside the function.
- **secure**: Whether the cookie should only
be sent over HTTPS (default is `false`).
**Example**:

```php **Disadvantages**:

<?php 1. **Requires more computational


resources**: SVMs can be slow when working
// Function to increment a value by reference with large datasets.
function increment(&$value) { 2. **Sensitive to Noise**: SVM can overfit if
$value++; there is a lot of noise in the data, particularly
when the margin is too narrow.
}
3. **Not Suitable for Larger Datasets**: SVM
$num = 5; is computationally expensive for large
datasets with many features.
increment($num); // Passing by reference
#### b) Explain **Data Frame** with
echo "Incremented value: " . $num; // Output:
example in R.
Incremented value: 6
A **data frame** in R is a table or 2D array-
?>
like structure that stores data of different
**Explanation**: types (numeric, character, etc.). It is one of
the most commonly used data structures in R
- The function `increment()` accepts the for storing datasets.
parameter by reference using `&$value`.
**Example**:
- Any change to `$value` inside the function
will modify the original `$num` variable. ```r

### R Questions: # Creating a data frame

Q3) a) State advantages and disadvantages df <- data.frame(


of **SVM (Support Vector Machine)**.
Name = c("John", "Jane", "Jim"),
**Advantages**:
Age = c(23, 25, 22),
1. **Effective in High Dimensional Spaces**:
Salary = c(50000, 55000, 49000)
SVM is very effective for high-dimensional
data, especially when the number of features )
is greater than the number of samples.
# Displaying the data frame
2. **Memory Efficient**: SVM uses a subset
of training points (support vectors) in the print(df)
decision function, which makes it memory **Explanation**:
efficient.
- A data frame can hold different types of
3. **Works well with both Linear and Non- columns (like numeric, character, etc.).
linear Data**: With the use of the kernel trick,
SVM can efficiently perform non-linear
classification.
- In this example, the `data.frame()` function #### d) What is a **Histogram**? Explain
is used to create a data frame with three with an example in R.
columns: `Name`, `Age`, and `Salary`.
A **histogram** is a graphical representation
**Output**: of the distribution of a dataset. It shows the
frequency of data points in predefined
``` intervals (bins).
Name Age Salary **Example**:
1 John 23 50000 ```r
2 Jane 25 55000 # Create a random dataset
3 Jim 22 49000 data <- rnorm(1000, mean = 50, sd = 10)
#### c) Explain types of regression models. # Plot a histogram
Regression models are used to predict a hist(data, main="Histogram of Random Data",
continuous output variable based on one or xlab="
more input features. Some common types of
regression models include: Values", ylab="Frequency", col="lightblue",
border="black")
1. **Linear Regression**:
**Explanation**:
- Predicts a continuous dependent variable
based on the linear relationship between the - `rnorm()` generates 1000 random values
input features and the output. from a normal distribution.

- Example: Predicting house prices based on - `hist()` creates a histogram to visualize the
square footage. frequency distribution of the data.

2. **Multiple Linear Regression**: #### e) Explain functions included in the


**"dplyr"** package.
- A generalization of linear regression that
uses multiple input variables to predict the The **dplyr** package in R provides a set of
dependent variable. functions for data manipulation. Some
commonly used functions include:
3. **Logistic Regression**:
1. **`select()`**: Selects specific columns
- Used for binary classification tasks. It from a data frame.
predicts the probability of the binary outcome
(0 or 1). 2. **`filter()`**: Filters rows based on
conditions.
4. **Polynomial Regression**:
3. **`mutate()`**: Adds new variables to the
- A type of regression that uses higher- data frame or modifies existing ones.
degree polynomials to fit non-linear
relationships between variables. 4. **`arrange()`**: Sorts the data based on
one or more variables.
Q4) a) **Explain the concept of sticky form }
with suitable example.**
?>
A **sticky form** refers to a form where the
data entered by the user is retained even <!-- HTML Form -->
after the form is submitted, especially when <form method="post" action="<?php echo
there are validation errors. This is helpful in htmlspecialchars($_SERVER["PHP_SELF"]);?
ensuring that the user does not have to re- >">
enter all the information if the form
submission fails. Name: <input type="text" name="name"
value="<?php echo $name; ?>">
In PHP, this can be achieved by using
`$_POST` to retain the entered data in the <span class="error">* <?php echo
form fields after the form is submitted. $nameErr; ?></span><br><br>

**Example**: Email: <input type="text" name="email"


value="<?php echo $email; ?>">
```php
<span class="error">* <?php echo
<?php $emailErr; ?></span><br><br>
// Define variables and initialize with empty <input type="submit" value="Submit">
values
</form>
$name = $email = "";
<?php
$nameErr = $emailErr = "";
// Display data if form is submitted
// Processing form when it's submitted successfully
if ($_SERVER["REQUEST_METHOD"] == if ($_SERVER["REQUEST_METHOD"] ==
"POST") { "POST" && empty($nameErr) &&
if (empty($_POST["name"])) { empty($emailErr)) {

$nameErr = "Name is required"; echo "<h2>Your Input:</h2>";

} else { echo "Name: $name<br>";

$name = $_POST["name"]; echo "Email: $email<br>";

} }

if (empty($_POST["email"])) { ?>

$emailErr = "Email is required";

} else {

$email = $_POST["email"];

}
#### b) **Explain Email ID validation in PHP **Example**:
through regular expression.**

Email validation in PHP can be done using


**regular expressions (regex)**. The regular ```php
expression pattern checks whether the <?php
entered email is in the correct format.
// Original array
**Example**:
$ages = array("John" => 25, "Jane" => 28,
```php "Jim" => 22);
<?php

$email = "[email protected]"; // Sort array in reverse order


if (preg_match("/^[a-zA-Z0-9._-]+@[a-zA-Z0- arsort($ages);
9.-]+\.[a-zA-Z]{2,6}$/", $email)) {

echo "Valid Email Address!";


// Display the sorted array
} else {
foreach ($ages as $name => $age) {
echo "Invalid Email Address!";
echo "$name: $age<br>";
}
}
?>
?>
**Explanation**:
**Explanation**:
- The regular expression `/^[a-zA-Z0-9._-]
+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/` ensures - `arsort()` sorts the `$ages` array in
that the email has the correct format: descending order while preserving the key-
value pairs.
- Begins with alphanumeric characters, dots,
underscores, or hyphens. - The `foreach` loop is used to display the
sorted array.
- Includes `@` symbol, followed by a valid
domain name. **Output**:

- Ends with a period followed by 2 to 6 Jane: 28


letters for the domain extension.
John: 25
#### c) **Write PHP program for `arsort()`
Jim: 22
function.**

The `arsort()` function sorts an array in


reverse order, maintaining key-value
associations.
#### d) **Write a PHP program to display
record of employee with fields (empid,
empname, salary, dept).** echo "</table>";

Here’s an example of a PHP script that ?>


displays employee records from an array: ```
```php

<?php **Explanation**:
// Employee records - An array `$employees` contains employee
$employees = array( records, each record is an associative array.

array("empid" => 101, "empname" => "John - A `foreach` loop is used to iterate over the
Doe", "salary" => 50000, "dept" => "HR"), records and display them in an HTML table.

array("empid" => 102, "empname" => "Jane #### e) **Write a PHP program to create
Smith", "salary" => 55000, "dept" => login page and welcome user on next
"Finance"), page.**

array("empid" => 103, "empname" => "Jim Here’s how you can create a simple login page
Brown", "salary" => 48000, "dept" => "IT") with PHP:

); **login.php** (Login Page):

// Displaying records ```php

echo "<table border='1'>"; <?php

echo "<tr><th>Employee // Start session


ID</th><th>Employee session_start();
Name</th><th>Salary</th><th>Department<
/th></tr>"; // Check if the form is submitted

foreach ($employees as $emp) { if ($_SERVER["REQUEST_METHOD"] ==


"POST") {
echo "<tr>";
// Validate login details
echo "<td>" . $emp['empid'] . "</td>";
$username = $_POST['username'];
echo "<td>" . $emp['empname'] . "</td>";
$password = $_POST['password'];
echo "<td>" . $emp['salary'] . "</td>";
if ($username == "admin" && $password ==
echo "<td>" . $emp['dept'] . "</td>"; "1234") {
echo "</tr>"; // Set session variable
} $_SESSION['username'] = $username;
header("Location: welcome.php"); // }
Redirect to welcome page

exit();
// Welcome the user
} else {
echo "Welcome, " . $_SESSION['username'] .
echo "Invalid credentials!"; "!";

} ?>

} **Explanation**:

?> - **login.php**: The login form accepts the


username and password. If the credentials are
<form method="post" action="login.php"> correct, it redirects to `welcome.php` and
Username: <input type="text" stores the username in the session.
name="username" required><br> - **welcome.php**: Displays a welcome
Password: <input type="password" message using the session variable. If the user
name="password" required><br> is not logged in, they are redirected back to
the login page.
<input type="submit" value="Login">
### **R Questions**:
</form>
Q4) a) **Explain Naive Bayes with the help of
``` an example.**

**Naive Bayes** is a classification algorithm


based on Bayes’ Theorem, assuming that
**welcome.php** (Welcome Page):
features are independent given the class
label. It’s simple yet effective for classification
tasks,
```php
**Example**:
<?php
If we want to classify whether an email is
// Start session spam or not, based on words in the email, the
Naive Bayes classifier would calculate the
session_start();
probability of an email being spam or not
based on the occurrence of certain keywords
(e.g., "offer", "buy", "free").
// Check if the user is logged in
The Naive Bayes formula is:
if (!isset($_SESSION['username'])) {
\[ P(Y|X) = \frac{P(X|Y)P(Y)}{P(X)} \]
header("Location: login.php"); // Redirect
to login page if not logged in Where:

exit();
- \( P(Y|X) \) is the probability that the email is fahrenheit <- as.numeric(readline(prompt =
of class \(Y\) (spam or not). "Enter temperature in Fahrenheit: "))

- \( P(X|Y) \) is the likelihood of the observed # Convert to Celsius


features given the class.
celsius <- (fahrenheit - 32) * 5 / 9
- \( P(Y) \) is the prior probability of the class.
# Print the result
#### b) **What is data visualization? Explain
with example in R.** cat("Temperature in Celsius:", celsius, "\n")

**Data visualization** is the graphical **Explanation**:


representation of data. It helps in - `readline()` accepts input from the user.
understanding trends, patterns, and outliers
in data. In R, packages like `ggplot2` and `plot` - The conversion formula `(Fahrenheit - 32) *
are commonly used for data visualization. 5 / 9` is used to convert Fahrenheit to Celsius.

**Example**: #### d) **Accept three dimensions length (l),


breadth (b), and height (h) of a cuboid and
```r print its volume.**
# Create a simple dataset # Accept dimensions from the user
data <- data.frame( length <- as.numeric(readline(prompt = "Enter
x = c(1, 2, 3, 4, 5), length of cuboid: "))

y = c(5, 4, 3, 2, 1) breadth <- as.numeric(readline(prompt =


"Enter breadth of cuboid: "))
)
height <- as.numeric(readline(prompt = "Enter
# Plot the data height of cuboid: "))

plot(data$x, data$y, type = "b", col = "blue", # Calculate the volume


pch = 19, xlab = "X-Axis", ylab = "Y-Axis", main
= "Simple Data Plot") volume <- length * breadth * height

**Explanation**: # Print the volume

- `plot()` creates a simple scatter plot with cat("Volume of the cuboid is:", volume, "\n")
blue points and lines connecting them. **Explanation**:
#### c) **Write a R program to accept - The volume of a cuboid is calculated using
temperatures in Fahrenheit (F) and print it in the formula: `length * breadth * height`.
Celsius (C).**

```r

# Accept Fahrenheit temperature as input


#### e) **Write an R program to accept any 2. **Password Input (`<input
year as input and check whether the year is a type="password">`)**: For secure input (e.g.,
leap year or not.** passwords).

```r ```html

# Accept year input <input type="password" name="password"


placeholder="Enter your password">
year <- as.numeric(readline(prompt = "Enter a
year: ")) 3. **Radio Buttons (`<input
type="radio">`)**: Allow users to choose one
# Check for leap year option from multiple.
if ((year %% 4 == 0 && year %% 100 != 0) || ```html
(year %% 400 == 0)) {
<input type="radio" name="gender"
cat(year, "is a leap year.\n") value="male"> Male
} else { <input type="radio" name="gender"
cat(year, "is not a leap year.\n") value="female"> Female

} 4. **Checkboxes (`<input
type="checkbox">`)**: Allow users to select
**Explanation**: multiple options.

- The conditions check whether a year is ```html


divisible by 4, but not divisible by 100 unless it
is also divisible by 400 to determine if it’s a <input type="checkbox" name="subscribe"
leap year. value="yes"> Subscribe to newsletter

Here are the answers to the questions you 5. **Select Dropdown (`<select>`)**: Provides
have provided: a dropdown list of options.

Q5) a) **Form and Form Elements** ```html

A **form** in HTML allows users to submit <select name="country">


data to a server for processing. The `<form>` <option value="us">United
element acts as a container for form elements States</option>
and includes attributes like `action` (URL
where data is sent) and `method` (HTTP <option value="uk">United
method, like `GET` or `POST`) Kingdom</option>

**Common Form Elements**: </select>

1. **Text Input (`<input type="text">`)**: For ```


short text input.

```html

<input type="text" name="username"


6. **Submit Button (`<input $x -= 3; // Equivalent to $x = $x - 3;
type="submit">`)**: A button that sends the
form data to the server. ```

```html

<input type="submit" value="Submit"> 4. **`*=` (Multiplication Assignment)**:


Multiplies the variable on the left by the value
**Example Form**: on the right.

```html ```php

<form action="submit.php" method="POST"> $x *= 2; // Equivalent to $x = $x * 2;

Name: <input type="text" 5. **`/=` (Division Assignment)**: Divides the


name="name"><br> variable on the left by the value on the right.

Email: <input type="email" ```php


name="email"><br>
$x /= 4; // Equivalent to $x = $x / 4;
<input type="submit" value="Submit">
6. **`%=` (Modulus Assignment)**: Takes the
</form> modulus of the variable on the left by the
value on the right.
#### b) **Assignment Operators in PHP**
```php
In PHP, assignment operators are used to
assign values to variables. The most common $x %= 3; // Equivalent to $x = $x % 3;
assignment operator is the simple assignment
`=`, but there are other shorthand operators #### c) **List Different PHP MySQLi
as well. Functions**

1. **`=` (Simple Assignment)**: Assigns the PHP's **MySQLi (MySQL Improved)**


value on the right to the variable on the left. extension provides functions for interacting
with MySQL databases. Here are some
```php commonly used MySQLi functions:

$x = 10; // Assigns 10 to $x 1. **`mysqli_connect()`**: Opens a new


connection to a MySQL server.
2. **`+=` (Addition Assignment)**: Adds the
value on the right to the variable on the left. ```php

```php $conn = mysqli_connect("localhost",


"username", "password", "database");
$x += 5; // Equivalent to $x = $x + 5;
2. **`mysqli_query()`**: Performs a query
3. **`-=` (Subtraction Assignment)**: against the MySQL database.
Subtracts the value on the right from the
variable on the left. ```php

```php $result = mysqli_query($conn, "SELECT *


FROM users");
3. **`mysqli_fetch_assoc()`**: Fetches a 1. **Hadoop**: An open-source framework
result row as an associative array. for distributed storage and processing of large
datasets using a cluster of commodity
```php hardware. It includes:
$row = mysqli_fetch_assoc($result); - **HDFS (Hadoop Distributed File
echo $row['username']; System)** for storage.

4. **`mysqli_fetch_row()`**: Fetches a result - **MapReduce** for processing.


row as a numeric array. 2. **Apache Spark**: A fast, in-memory data
```php processing engine for big data analytics. It
supports batch and real-time processing, and
$row = mysqli_fetch_row($result); can work with data in various formats (like
HDFS, S3).
echo $row[0]; // Access by column index
3. **NoSQL Databases**: Tools like
5. **`mysqli_num_rows()`**: Returns the
**MongoDB**, **Cassandra**, and
number of rows in a result set.
**HBase** are used to store unstructured
```php and semi-structured data.

$count = mysqli_num_rows($result); 4. **Apache Kafka**: A distributed event


streaming platform used to handle real-time
6. **`mysqli_insert_id()`**: Returns the ID of data feeds.
the last inserted record.
5. **Tableau**: A data visualization tool that
```php is often used for analyzing large datasets and
creating interactive dashboards.
$last_id = mysqli_insert_id($conn);
6. **ElasticSearch**: A distributed search and
7. **`mysqli_close()`**: Closes the previously
analytics engine commonly used to process
opened MySQL connection.
and analyze large amounts of structured data.
```php
#### b) **Advantages of Big Data**
mysqli_close($conn);
1. **Improved Decision-Making**: Big data
8. **`mysqli_prepare()`**: Prepares an SQL helps businesses and organizations make
query for execution. better decisions by providing valuable insights
and trends.
```php
- Example: Predictive analytics can help
$stmt = mysqli_prepare($conn, "SELECT * businesses forecast demand, optimize supply
FROM users WHERE username = ?"); chains, and personalize marketing.

Q5) a) **Tools Used in Big Data** 2. **Increased Efficiency and Productivity**:


With advanced data analytics, companies can
Big data proessing involves various tools to
streamline operations and reduce waste. This
manage, analyze, and visualize large datasets.
results in improved productivity and lower
Some of the commonly used tools are:
operational costs.
- Example: Machine learning algorithms can 2. **Computationally Expensive**: The
automate routine tasks, enhancing algorithm can be slow, especially for large
operational efficiency. datasets, as it involves multiple iterations of
the Expectation and Maximization steps.
3. **Better Customer Insights**: Big data
allows companies to track customer behavior 3. **Assumes Conditional Independence**:
and preferences. This enables them to offer EM assumes that the data is conditionally
more personalized services or products. independent, which might not always hold in
real-world scenarios.
- Example: Retailers like Amazon and Netflix
use big data to provide personalized
recommendations based on user activity.

4. **Competitive Advantage**: Big data


analysis can give companies a competitive
edge by identifying market trends, consumer
behavior, and business opportunities faster
than competitors.

#### c) **Advantages and Disadvantages of


EM Algorithms**

The **Expectation-Maximization (EM)**


algorithm is an iterative method used to
estimate parameters in probabilistic models,
often for missing or incomplete data.

**Advantages**:

1. **Handles Missing Data**: EM is


particularly useful when dealing with missing
or incomplete data, as it estimates the
missing values during the process.

2. **Flexibility**: It can be applied to various


types of problems, including clustering (e.g.,
Gaussian Mixture Models) and parameter
estimation.

3. **Convergence**: The EM algorithm is


guaranteed to converge to a local maximum
of the likelihood function.

**Disadvantages**:

1. **Local Optima**: EM is prone to getting


stuck in local optima rather than finding the
global maximum, especially when the initial
parameters are poorly chosen.

You might also like