Web Data Management - Quiz #2

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

If you want to generate a random number that ranges from 1000 to 500,000 as a multiple of 100 (1000, 1100, 1200, etc.), and store it in a variable named $number, you can use the code that follows. a. $number = mt_rand(10,5000); $number *= 100; b. $number = mt_rand(1000,500000); c. $number = mt_rand(1,500); $number *= 1000; d. $number = mt_rand(100,50000); $number *= 10;

a. $number = mt_rand(10,5000); $number *= 100;

Which character is used to separate parameters that are appended to a URL? a. & b. $ c. ? d. =

a. &

If the date is December 25, 2014, what output would be produced by the code below? echo date('n/j/Y'); a. 12/25/2014 b. 12/25/14 c. Dec. 25, 2014 d. December 25, 2014

a. 12/25/2014

Which method of the form appends values to the URL to pass data? a. GET b. ACTION c. POST d. APPEND

a. GET

Variable substitution is carried out by what process that converts a variable's value to a string? a. interpolation b. decimation c. coercion d. encapsulation

a. interpolation

Which PHP function can be used to determine if a checkbox is checked? a. isset b. is_checked c. boolean d. value

a. isset

Which of the following is a relational operator in PHP? a. > b. < c. <= d. all of these

d. all of these

Which of the following is NOT an escape sequence used in double-quoted strings in PHP? a. /t b. /c c. /n d. /r

b. /c

If the date is December 25, 2014, what output would be produced by the code below? echo date('n/j/y'); a. 12/25/2014 b. 12/25/14 c. December 25, 2014 d. Dec. 25, 2014

b. 12/25/14

Which method of a DateTime object can be used to determine an amount of time between two dates or times? a. datebetween b. diff c. add d. datediff

b. diff

Which of the following is a PHP function used to get random numbers? a. next_random b. mt_rand c. rand_num d. rnum

b. mt_rand

What does $message contain after the following code executes? $message = "L: "; for ($i = 0; $i < 10; $i++ ) { $message .= $i . ", "; if ($i == 7) break; } a. L: 0, 1, 2, 3, 4, 5, 6, 7, b. L: 1, 3, 5, 7, 9, c. L: 1, 3, 5, 7 d. L: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

a. L: 0, 1, 2, 3, 4, 5, 6, 7,

Assume that the statements that follow get the data from a text area named comments. After these statements are executed, how will the $comments_esc variable be displayed by an echo statement? $comments = filter_input(INPUT_POST, 'comments'); $comments_esc = htmlspecialchars($comments); a. With character entities for special characters b. With <br> tags for new line characters c. With both character entities and <br> tags d. With character entities for both special characters and new line characters

a. With character entities for special characters

Which of the following is a way to assign a string to a variable in PHP? a. all of these b. single quotes c. double quotes d. heredoc

a. all of these

Which type of input element should be used on a form when the user can select zero, one, or many of the options in a group? a. checkbox b. submit c. text d. radio

a. checkbox

Which type of statement ends the current iteration of a loop? a. continue b. break c. switch d. conditional

a. continue

When you use the htmlspecialchars and nl2br functions to process a user's entry and then pass that entry to a web page, the browser will a. display the any HTML tags entered by the user instead of processing them b. process any HTML tags that the user entered instead of displaying them c. ignore any line breaks entered by the user d. execute any JavaScript code entered by the user

a. display the any HTML tags entered by the user instead of processing them

Which type of loop will always execute its code at least once? a. do-while b. while c. for-in d. for

a. do-while

A hidden field a. doesn't appear on the form but its data is sent to the server b. appears on the form with its data grayed out c. has data that is obscured by bullets or asterisks d. appears on the form but its data is hidden

a. doesn't appear on the form but its data is sent to the server

In order to group multiple radio buttons so that only one of the radio buttons can be selected at a time, which attribute of the input element must have the same value for all radio buttons in the group? a. name b. id c. value d. checked

a. name

If you want to round a number within an arithmetic expression, which function should you use? a. round b. number_format c. sprintf

a. round

Which HTML element is used to create a drop-down list? a. select b. list c. input d. drop-down

a. select

Which PHP function returns the number of characters in the string? a. strlen b. substr c. len d. countchars

a. strlen

A ______________ is an integer that represents a date and time as the number of seconds sincemidnight, January 1, 1970. a. checkdate b. intdate c. timestamp d. date_format

c. timestamp

If the date is December 25, 2014, what output would be produced by the code below? echo date('n/d/Y h:i A'); a. 12/25/2014 b. December 25, 2014 c. 12/25/14 d. 12/25/2014 12:00 AM

d. 12/25/2014 12:00 AM

How many radio buttons from the following code can be selected at any given time? <input type="radio" name="address" value="Home">Home Address <input type="radio" name="delivery" value="FedEx">Federal Express <input type="radio" name="delivery" value="UPS">UPS a. 3 b. 1 c. 0 d. 2

d. 2

Which character is used to separate the original URL from the parameters that are appended to it? a. $ b. = c. & d. ?

d. ?

If the date is December 25, 2014, what output would be produced by the code below? echo date('M. d, Y'); a. December 25, 2014 b. 12/25/2014 c. 12/25/14 d. Dec. 25, 2014

d. Dec. 25, 2014

Assume that the second radio button in the code below has been selected by the user. When you get the value of that radio button, what will the value be? <input type="radio" name="delivery" value="USPS">USPS <input type="radio" name="delivery" value="FedEx">Federal Express <input type="radio" name="delivery" value="UPS">UPS a. federal express b. fedex c. Federal Express d. FedEx

d. FedEx

What does $message contain after the following code executes? $statusCode = "403"; switch ( $statusCode ) { case "200": $message = "OK"; break; case "403": $message = "Forbidden"; break; case "404": $message = "Not Found"; break; default: $message = "Unknown Status"; break; } a. Unknown Status b. OK c. Not Found d. Forbidden

d. Forbidden

What does $message contain after the following code executes? $rate = 0.1; if ( ! is_numeric($rate) ) { $message = 'Rate is not a number.'; } else if ($rate < 0) { $message = 'Rate cannot be less than zero.'; } else if ($rate > 0.2) { $message = 'Rate cannot be greater than 20%.'; } else { $message = 'Rate is valid.'; } a. Rate cannot be greater than 20%. b. Rate cannot be less than zero. c. Rate is not a number. d. Rate is valid.

d. Rate is valid.

What is stored in $message by the code that follows? $message = "The file is in \"C:\\My Documents\""; a. The file is in "C:\\My Documents\" b. The file is in C:\\My Documents\ c. The file is in C:\My Documents d. The file is in "C:\My Documents"

d. The file is in "C:\My Documents"

What does $message contain after the following code executes? $age = 19; $score = 750; if ( $age >= 21 && $score >= 700 ) { $message = 'Loan approved'; } else if ( $age >= 21 && $score >= 650 ) { $message = 'Cosigner needed.'; } else if ( $age >= 18 && $score >= 680 ) { $message = 'Two cosigners needed.'; } else { $message = 'Loan denied.'; } a. Loan approved. b. Load denied. c. Cosigner needed. d. Two cosigners needed.

d. Two cosigners needed.

Which of the following can be used in a conditional expression? a. equality operators b. relational operators c. logical operators d. all of these

d. all of these

A switch statement in PHP start by evaluating a switch ________________. a. return statement b. case c. break d. expression

d. expression

Which PHP function converts some special characters into character entities? a. convertchars b. double_encode c. substr d. htmlspecialchars

d. htmlspecialchars

While loops and for loops are often referred to as ________________ structures. a. selection b. sequence c. ill-advised d. iteration

d. iteration

Which attribute of a form element determines how the data is passed to a file? a. default b. action c. submit d. method

d. method

Which HTML element is used to create items in a drop-down list? a. item b. value c. list d. option

d. option

Which type of input element should be used on a form when the user can select only one of the options? a. checkbox b. submit c. radio d. text

c. radio

How many operands does a ternary operator have? a. 1 b. 3 c. 2 d. 4

b. 3

To create a DateTime object that represents a due date that's 90 days after the current date, you use the following code: a. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date + $days; b. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date->add($days); c. $days = new DateInterval('P90D'); $due_date = date(); $due_date = $due_date->add($days); d. $days = new DateInterval('P90D'); $due_date = date(); $due_date = $due_date + $days

b. $days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date->add($days);

Suppose that $name contains a last name followed by a comma and a space, followed by a first name. Then, you can store the first and last names in variables with code like this: a. $i = strpos($name, ', '); $first_name = substr($name, 0, $i); $last_name = substr($name, $i+2); b. $i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+2); c. $i = strpos($name, ', '); $first_name = substr($name, 0, $i); $last_name = substr($name, $i+1); d. $i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+1);

b. $i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+2);

$current_date = new DateTime(); $due_days_diff = $current_date->diff($due_date); if ($current_date > $due_date) { $overdue_message = $due_days_diff->format( '%y years, %m months, and %d days overdue.'); } (Refer to code example 10-1) If $due_date contains a DateTime object for a date that comes 1 month and 7 days before the date stored in the $current_date variable, what will $overdue_message contain when this code finishes executing: a. $overdue_message won't be set because the if clause won't be executed b. 0 years, 1 months, and 7 days overdue. c. 1 month and 7 days overdue. d. -0 years, -1 months, and -7 days overdue.

b. 0 years, 1 months, and 7 days overdue.

If the date is December 25, 2014, what output would be produced by the code below? echo date('F d, Y'); a. 12/25/14 b. December 25, 2014 c. 12/25/2014 d. Dec. 25, 2014

b. December 25, 2014

A switch statement in PHP is often useful in the ________________ of an application that uses the MVC pattern. a. header b. controller c. view d. model

b. controller

Which PHP function returns a string with all special HTML converted to the HTML entity? a. encode_entity b. htmlentities c. converthtml d. htmlencode

b. htmlentities

Which optional attribute of a select element allows the user to select more than one option in a list box? a. plural b. multiple c. size d. morethanone

b. multiple

A "natural" comparison of two values a. puts "10" before both "09" and "9" b. puts both "09" and "9" before "10" c. is case-insensitive d. is case-sensitive

b. puts both "09" and "9" before "10"

When you create a DateInterval object, you pass it one argument that specifies one or more of the following: a. years, months, days b. years, months, weeks, days, hours, minutes, seconds c. hours, minutes, seconds d. years, months, days, hours, minutes, seconds

b. years, months, weeks, days, hours, minutes, seconds

Which of the following statements is NOT a valid way to create a timestamp named $birthdate that represents December 2, 1969? a. $birthdate = mktime(0, 0, 0, 12, 2, 1969); b. $birthdate = strtotime('12/02/1969'); c. $birthdate = mktime(12, 2, 1969); d. $birthdate = strtotime('1969-12-02');

c. $birthdate = mktime(12, 2, 1969);

Assume that the POST method is used. Which of the following statements gets the value of the radio button that's on in the delivery group and stores it in a variable named $card_type? <input type="radio" name="delivery" value="USPS">USPS <input type="radio" name="delivery" value="FedEx">Federal Express <input type="radio" name="delivery" value="UPS">UPS a. $card_type = isset($_POST['delivery'];) b. $card_type = filter_input(INPUT_POST, 'card_type'); c. $card_type = filter_input(INPUT_POST, 'delivery'); d. $card_type = isset($_POST['card_type'];

c. $card_type = filter_input(INPUT_POST, 'delivery');

Suppose that $name contains a last name followed by a comma and a space, followed by a first name. Then, you can store the first and last names in variables with code like this: a. $name = explode(', ', $name); $last_name = $name[1]; $first_name = $name[0]; b. $name = implode(', ', $name); $last_name = $name[1]; $first_name = $name[0]; c. $name = explode(', ', $name); $last_name = $name[0]; $first_name = $name[1]; d. $name = implode(', ', $name); $last_name = $name[0]; $first_name = $name[1];

c. $name = explode(', ', $name); $last_name = $name[0]; $first_name = $name[1];

Which of the following is the correct syntax for using a conditional operator? a. (conditional_expression) ? value_if_false : value_if_true b. (conditional_expression) : value_if_false ? value_if_true c. (conditional_expression) ? value_if_true : value_if_false d. (conditional_expression) : value_if_true ? value_if_false

c. (conditional_expression) ? value_if_true : value_if_false

Which of the following operators does NOT perform type coercion? a. == b. != c. === d. >=

c. ===

Timestamps will encounter a(n) _______ problem if they are not converted to DateTime objects. a. Y69K b. Y2K c. Y2K38 d. Y10K

c. Y2K38

$current_date = new DateTime(); $due_days_diff = $current_date->diff($due_date); if ($current_date > $due_date) { $overdue_message = $due_days_diff->format( '%y years, %m months, and %d days overdue.'); } (Refer to code example 10-1) If $due_date contains a DateTime object, $due_date_diff will contain a. a TimeStamp object b. a DateTime object c. a DateInterval object d. a TimeInterval object

c. a DateInterval object

Which type of statement ends or jumps out of a loop? a. continue b. for c. break d. next

c. break

Which of the following statements will restart the execution of a loop? a. break b. stop c. continue d. halt

c. continue

An if statement can be used to implement a ________________ structure. a. sequence b. case c. selection d. logical

c. selection

When you use the substr function to extract a substring from a string, you need to at least pass an argument that gives a. the characters in the substring that you're looking for b. the length of the substring c. the starting position of the substring d. the separators for the substring

c. the starting position of the substring


Kaugnay na mga set ng pag-aaral

MKT 574: Chapter 8: Product strategy and new product development

View Set

The Process of Creative Destruction

View Set

Simplilearn Six Sigma Black Belt Sample Test

View Set

Chapter 28 Water and salt physiology in different environments

View Set

Chapter 3. Basics of behavior change

View Set