Exam 2 pt 2

Ace your homework & exams now with Quizwiz!

Which character is used to signify the end of a string in a PHP regular expression?

$

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

$card_type = $_POST['delivery'];

Given the code:$employee = array();$employee["name"] = "John Smith";$employee["age"] = 29;which of these statements assigns "John Smith is 29" to $message?

$message = $employee["name"] . " is " . $employee["age"];

Which character is used to signify the beginning or the end of a word in a PHP regular expression?

/B

Which of the following will match any character that is NOT a letter, number, or underscore in a PHP regular expression?

/W

This pattern can be used to validate a five-digit zip code:

/^\d{5}$/

Which of the following will match any digit in a PHP regular expression?

/d

Which of the following will match any letter, number, or underscore in a PHPregular expression?

/w

If the key is omitted when adding a value to an array, and there were no integer indexes added, PHP assigns an index of ______________________ to the element.

0

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

2

Because most systems today store timestamps as 32-bit signed integers, the upper limit of a timestamp on these systems is January 19 in the year ________________________________.

2038

The ________________________________ function returns an array of elements that exist in one array but not in any other arrays to which it is compared.

Array_diff()

Why is it important not begin an integer value with a zero (e.g., 03), when working with numbers in calculations?

Because it would be treated as an octal value, and yield an incorrect result.

The diff method of a DateTime object requires another DateTime object as its argument and returns a ___________________________________ object.

DateInterval

$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, % months, and %d days overdue.;)'}If $due_date contains a DateTime object, $due_date_diff will contain

DateInterval object

One of the methods of a __________________________________ object l;ets you add a DateInterval object to the object.

DateTime

The use of ____________________________________ objects resolves the Y2K38 problem because the upper limits of dates and times are essentially removed.

DateTime

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

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;} Forbidden

Forbidden

If a number in a PHP application is larger than the maximum value that PHP provides for, it is converted into the PHP constant named ____________________________________.

INF

___________________________________ provides an object-oriented approach to working with a variety of database servers.

PDO

When you use the exception error mode, PHP throws a ______________________ object when a PDO error occurs.

PDOException

After you run prepared statement with PDO, you can use the fetchAll method of the ______________________________ object to get an array that corresponds with the rows in the result set.

PDOStatement

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.';}

Rate is valid.

With the use of the following escape sequences, what is stored in $message by the code that follows?$message = "The file is in \"C:\\My Documents\"";

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.';}

Two cosigners needed

Assume that the statements that follow get the data from a text area named comments. After these statements are executed, how will the $comments variable be displayed by an echo statement? $comments = $_POST['comments'];$comments = htmlspecialchars($comments);

With (HTML) character entities for special characters

Which of the following statements about associative arrays is NOT true?

You can use a foreach loop to access the values of an array but not the indexes

Which character is used to signify the beginning of the string in a PHP regular expression?

^

When you use session tracking, each HTTP request includes

a cookie that stores the session ID

A multidimensional array in PHP is essentially ___________________.

an array of arrays

Regular expressions

are limited to the validation of string data

The ____________________ function determines whether a given index or key exists.

array_key_exists()

Merge two or more arrays with the _______________________ function.

array_merge()

The _____________________ argument of the array_splice() function indicates the name of the array you want to modify.

array_name

Which of the following functions removes and returns the last (or next) element in a LIFO array (aka stack)?

array_pop

Which of the following functions will add an element to the end of a LIFO array (aka stack)?

array_push

The _______________________ function lets you add or remove elements anywhere else in the array.

array_search()

Which of the following functions removes and returns the first element in a FIFO array (aka queue)?

array_shift

You use the ________________________________ function to return a portion of an array and assign it to another array.

array_slice()

The ________________________ function lets you add or remove elements anywhere else in the array.

array_splice()

The __________________________ function removes duplicate elements from an array.

array_unique()

Which of the fo9llowing functions will add an element to the beginning of a FIFO array (aka queue)>

array_unshift

To renumber an indexed array's elements, you need to run the _____________________________ function.

array_values()

When you use a prepared SQL statement with PDO, you need to ____________________________ the parameters to variable values before you can run the statement.

bind

The strcasecmp is _________________________________. As a result, "Anders" comes before "zylka".

case-insensitive

If you want to code a catch block that catches all types of exeptions and gets the message associated with the exception, you start the catch clock like this:

catch (PDOException $e) {

Which of the following statements will restart the execution of a loop?

continue

Type casting refers to PHP code that converts a value from one _______________________________ to another.

data type

The explode function returns an array of strings from a single string based on the ______________________________ character that you specify.

delimiter

Which type of loop will always execute its code at least once?

do-while

A hidden field:

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

In order to print out a variable's value, when you code a variable name within a string literal, you have to enclose the literal within ___________________________________ quotation marks.

double

To remove multiple elements using the unset() function, separate each ____________________________ name with commas.

element

By using ______________________________________, you can put special characters into a string literal that would otherwise be interpreted incorrectly by PHP.

escape sequences

Runtime errors that occur due to unexpected error conditions are called _______________________________.

exceptions

Suppose an array of country codes and country names is created with a statement like this:$country_code = array('DEU' => 'Germany', 'JPN' => 'Japan', 'ARG' => 'Argentina', 'USA' => 'United States');

foreach ($county_codes as $code => $name){...

When you use the procedural interface of mysqli, you use __________________________ to do the database operations.

functions

To get the message that's related to an exception, you use

getMessage property of the exception class

The lastInsertID method of the PDO class

gets the ID for the last record with an auto-increment ID that has been inserted into a database

By using the ___________________________ function, you can send special characters to the browser in a way that they will be displayed correctly.

htmlentitites

What modifier can be added to the end of a regular expression in PHP to make it case insensitive?

i

If an if statement, which is a correct right way to find out whether the string in $a comes before (is less than) the string in $b in a case-insensitive comparison?

if ((strtolower($a) < (strtolower($b)))

The ____________________________ function returns a Boolean value of true if a given value exists in the array.

in_array()

The $_SESSION variable for a session

is an associative array

One disadvantage of using mysqli is that

it can only be used with MySQL

To perform a reverse sort on an associative array by key and maintain the existing keys, use the ________________________.

krsort()

To sort an associative array by key, use the _______________________ function.

ksort()

A substring within a string is identified by its _____________________________________ and its _____________________________________ within the string.

length, starting position

The ___________________________________ function returns the largest value of the two or more arguments that are passed to it.

max()

The prepare method of a PDO object

must be run before values are assigned to the parameters in a prepared statement

In the object-oriented interface for mysqli, you use the query method to run a SELECT statement. In the procedural interface, you use this function:

mysqli_query

To create a DateTime object for the current date, you use the __________________________________ and pass no arguments to the constructor.

new keyword

A DateInterval object represents a/an ____________________________ time.

period of

Which function searches for a regular expression in a string and returns 1 if the pattern is found?

preg_match

Which of the following are coded patterns that you can use to search for matching patterns in text strings?

regular expressions

The Itrim and rtrim functions let you __________________________________ from the front or back of a string.

remove all spaces

The date function makes it easy to create a timestamp for the current date and then ____________________________ before returning the value.

return a string formatted as a date

If you want to round a number within an arithmetic expression, which function should you use?

round

A timestamp stores the number of ___________________________________ since midnight on January 1, 1970 GMT.

seconds

To delete a cookie, youa. delete the $_COOKIE variable

set the cookie's value to an empty string and its expiration date to a time in the past

After you create a DateTime object, you can use its setTime method to change the time or its ___________________________ method to change the date.

setDate

A list of functions or methods in the revers order in which they were called is a(n) ____________________________________.

stack trace

Which of the following functions returns the length of a string?

strlen()

The easiest way to perform a mathematical calculation, and add the values of all the elements in an array is to use:

the array_sum function

When you use the substr function to extract a substring from a string, you need to at least pass an argument that gives

the starting position of the substring

Multidimensional arrays are not limited to ______________________.

two dimensions

When you use the exception error mode with PDO objects, you can

use try-catch statements to handle the exceptions that occur

The value of the htmlspecialchars and nl2br functions is that they let you display

user entries just as they were entered

Using strnatcasecmp($str1, $str2) function for a "natural" comparison of two values

would evaluate both "09" and "9" as being before "10"

When you create a DateInterval object, you can use the format() method, and pass it a number of arguments that specifies a format code for one or more of the following descriptions:

years, months, days, hours, minutes, seconds, and sign (+ or -) of the date interval


Related study sets

CHAPTER 19: DEEDS AND TRANSFER OF TITLE

View Set

Marketing Research - Midterm (Chapters 1-6)

View Set

Health Insurance Policy Provisions

View Set