Quiz 9 & 10 Flashcards

1
Q

T/F - JSON objects are wrapped in square brackets []

A

False

They’re wrapped in curly braces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

T/F - in PHP the try block represents block of code in which exception can arise.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T/F - The error_reporting setting specifies whether error messages should or should not be displayed in the browser.

A

False. That is the display_error setting.

The error_reporting setting specifies which type of errors are to be reported

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In php, any files that are sent to the server (via a web form) are held in the ______ array.

A

$_FILES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

T/F - The json_decode() function is used to convert a JSON encoded string into a PHP datatype

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In the following code, what is the purpose of the isset function?

if (isset($_POST[‘name’]) && empty(trim($_POST[‘name’])))

{

echo “<p class="alert">Form is missing data<p>”; $form_complete=false;

}

A

To determine whether the name element has been retrieved

Isset checks whether a variable is set (declared & not null) and returns a boolean value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the main advantage of sessions over cookies?

A

Data is stored on the server for sessions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

T/F - The $_FILES variable is an associative array like $_GET and $_POST

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F - JSON keys are always numbers, while JSON values can be a string, number, Boolean, null, object, or an array

A

False

Keys are always strings

Values can be anything

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

T/F - When an HTML form uses method=”get” and submits to a PHP script, $_GET will contain all the values entered in the form.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What method sends input to a PHP script via the URL?

A

GET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

PHP - Which statement would correctly function to create an associative array?

A $age=array(Bob => 5, Jim=> 7, Ted=> 12);
B $age=array(‘Bob’ => 5; ‘Jim’=> 7; ‘Ted’=> 12);
C $age=array(‘Bob’ => 5, ‘Jim’=> 7, ‘Ted’=> 12);
D $age=array(‘Bob’ = 5, ‘Jim’= 7, ‘Ted’ = 12)

A

C

PAY ATTENTION TO THE COMMAS, SINGLE QUOTES AROUND NAMES, ARROWS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the value displayed when the following is executed? Assume that the code was executed using the following URL:
testscript.php?c=25
<?php
function process($c, $d = 25)
{
global $e;
$retval = $c + $d - $_GET[‘c’] - $e;
return $retval;
}
$e = 10;
echo process(5);
?

A

-5.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

For a MySQL procedural connection, what is required?

$conn = ______________($__________, $________, $________);

A

$conn = mysqli_connect($servername, $username, $password);

4 Variables needed are: servername, database, username, password

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The query() method of a MySQLi object will return a _________________ object.

A

mysqli_result

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In PHP in order to access MySQL database you will use the:

A

mysqli_connect() function

mysql_connect also works but is deprecated