Search Header Logo
IDT105 Recitation

IDT105 Recitation

Assessment

Presentation

Computers

University

Practice Problem

Medium

Created by

Wency Jorda

Used 1+ times

FREE Resource

3 Slides • 13 Questions

1

media

2

Multiple Choice

What is the correct way to create an indexed array in PHP?

1

array = ("apple", "banana");

2

$array = array("apple", "banana");

3

$array[] = ("apple", "banana");

4

create_array("apple", "banana");

3

Multiple Choice

How do you access the second item in the following

array: $fruits = array("apple", "banana", "cherry");?

1

fruits[1];

2

$fruits[1];

3

$fruits[2];

4

$fruits{1};

4

Open Ended

Create a multidimensional array representing 3 users.

Each user must have a name, a nested array of 3 purchased products, and a nested associative array for their shipping address (city, province, zip)

5

media

6

Multiple Choice

Which of the following statements correctly sorts an associative array $a in descending order by value?

1

asort($a);

2

ksort($a);

3

arsort($a);

4

rsort($a);

7

Multiple Choice

What does array_keys(array("a" => 0, "b" => null, "c" => false), null, true) return?

1

["c"]

2

[]

3

["a", "b", "c"]

4

["b"]

8

Multiple Choice

Which method is more secure for transmitting sensitive form data?

1

REQUEST

2

GET

3

POST

4

C

9

Multiple Choice

What would $_REQUEST["name"] return if both GET and POST forms submitted a "name" field?

1

An array with both values

2

Depends on PHP configuration

3

Always the GET value

4

Always the POST value

10

Open Ended

Create a login form that uses htmlspecialchars() to prevent XSS and isset() to prevent undefined index errors.

11

media

12

Multiple Choice

Which function is best suited for validating an email address format?

1

preg_match()

2

isset()

3

explode()

4

strpos()

13

Multiple Choice

Which is false about $_COOKIE?

1

It is set with setcookie()

2

It can persist after the browser closes

3

It is stored on the client machine

4

It is encrypted by default

14

Multiple Choice

What is the output of this code?

$_GET["x"] = "<script>alert('x')</script>";

echo htmlspecialchars($_GET["x"]);

1

Escapes HTML and executes script

2

Prevents script execution

3

Displays alert popup

4

Echoes raw HTML

15

Open Ended

Explain the difference between $_POST, $_GET, and $_REQUEST. Provide examples when each is preferable.

16

Multiple Choice

What does this return?

$email = "user@example.com";

if (filter_var($email, FILTER_VALIDATE_EMAIL)) echo "Valid";

else echo "Invalid";

1

Error

2

Nothing

3

Valid

4

Invalid

media

Show answer

Auto Play

Slide 1 / 16

SLIDE