CIST2351-PHP Programming I - Final Prep

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

To get the value of a cookie, you can use the autoglobal ______________ variable.

$_COOKIE

If the date is December 25, 2014, what output would be produced by the code below? echo date('n/j/y');

12/25/14

If the date is December 25, 2014, what output would be produced by the following code? echo date('n/j/y');

12/25/14

If the date is December 25, 2014, what output would be produced by the code below? echo date('n/d/y h:i A');

12/25/2014 12:00 AM

What will the value of the $totals_string variable be after the following code is executed? $totals = array(141.95, 212.95, 411, 10.95); $totals[2] = 312.95; $totals_string = ''; for ($i = 0; $i < count($totals); $i++){ $totals_string .= $totals[$i] . "|"; }

141.95|212.95|312.95|10.95|

If a request is not sent, a session will end by default after ________________ have passed.

24 minutes

How many operands does a ternary operator have?

3

What output would be produced by the code below? $names = array('Ron Burgundy', 'Brick Tamland', 'Champ Kind', 'Veronica Corningstone', 'Brian Fantana'); echo $names[1];

Brick Tamland

________________ provide a way for a web application to store information in the user's web browser and retrieve it every time the user requests a page.

Cookies

If the date is December 25, 2014, what output would be produced by the code below? echo date('M. d, Y');

Dec. 25, 2014

If the date is December 25, 2014, what output would be provided by the code below? echo date('F d, Y');

December 25, 2014

To avoid the duplication of function names, you can

Use namespaces

You can deal with gaps in an array in all but one of the following ways. Which one is it?

Use the array_fill function to replace all gaps in the array with empty strings

Timestamps will encounter a(n) _____ problem if they are not converted to DateTime objects.

Y2K38

Which of the following is a PHP function that returns the sum of the elements in an array?

array_sum

Which method of passing a variable allows the function to change the value of the variable?

by reference

Which of the following is a function that is passed as an argument to another function?

callback

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

continue

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

A fundamental concept of object-oriented programming that groups related data and functionality in a class is called ____________________.

encapsulation

A switch statement in PHP starts by evaluating a switch _____ .

expression

Suppose an array of country codes and country names is created with a statement like this: $country_codes = array('DEU => 'Germeny', 'JPN' => "Japan', 'ARG" => 'Argentina', 'USA' => 'United States'); If you want to use echo statements to display a table of all of the codes and names, you could code those statements within a loop that starts like this:

foreach ($country_codes as $code => $name) {

All of the arguments that are passed to a function are available in an array that can be accessed by using the

func_get_args function

Which attribute of a form element determines how the data is passed to a file?

method

Which optional attribute of a select element allows the user to select more than one option in a list box?

multiple

When a new class extends a superclass, it inherits the properties and methods of the superclass. Then, it can

override the inherited methods

When creating functions, you can include ______________ that are located inside parentheses after the function name.

parameters

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 variables that store the data for a class?

properties

To prevent other classes from directly accessing the properties of a class, you can code them as private. Then, to make them available to other classes, you can code

public methods to set and get their values

A "natural" comparison of two values

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

Which type of input element should be used on a form when the user can select only one of the options?

radio

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

regular expressions

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

round

Which term describes locations in the code that have access to a variable?

scope

Which HTML element is used to create a drop-down list?

select

An if statement can be used to implement a _____ structure.

selection

Which PHP function can be used to end a session?

session_destroy

To delete a cookie, you

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

Which of the following is a PHP function that shuffles the values in an array in a random order?

shuffle

The easiest way to add the values in an array is to use

the array_sum function

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

the starting position of the substring

A _____ is an integer that represents a date and time as the number of seconds since midnight, January 1, 1970.

timestamp

By default, all arguments passed to PHP functions are passed by ________________.

value

Assume that the POST method is used. Which of the following statmenbts gets the value of the radio button that's on in the delivery group and stores it in a variable named $card_type? USPS >Federal Express >UPS

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

To refer to a public property named categoryName for an object that's referenced by $category, you code

$category->categoryName

Which method of the form appends values to the URL to pass data?

GET

What does $message contain after the following code executes? $message = "L: "; for ($i = 0: $i < 10; $i++) $message .= $i . ", "; if (i == 7) break;

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

Regular expressions

can be used to completely validate some types of user entries

Which of the following is a nested function that has access to the outer function's local variables?

closure

Which of the following is a special method executed when a new object is created from a class?

constructor

Which type of statement ends the current iteration of a loop?

continue

A subclass can ____________ the superclass by adding new properties and methods.

extend

Which PHP function is used to create a cookie?

setcookie

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

stack trace

Once a session is started, which autoglobal can be used to get and set the user's data for a session?

$_SESSION

Which of the following statements is NOT a valid way to create a timestamp named $birthdate that represents December 2, 1969?

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

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.

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

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

/^\d{5}$/

Which of the following is NOT an escape sequence used in double-quoted strings in PHP?

/c

Which of the following will match a new line in a PHP regular expression?

/n

Which character is used to separate the original URL from the parameters that are appended to it?

?

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

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"

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);

With 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 associative array but not the indexes

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

\W

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

\b

When you use session tracking, each HTTP request includes

a cookie that stores the session ID

Which of the following can be used in a conditional expression?

all of these

Which of the following is a PHP function for sorting arrays?

all of these

Which of the following is a parameter of the setcookie function?

all of these

Which of the following is a way to assign a string to a variable on PHP?

all of these

Which of the following is a PHP function that is used to count the number of times each value in an array is used?

array_count_values

If you create a function that passes an argument by reference, the function

can change the original variable without using a return statement

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

catch (Exception $e) {

Which PHP function can be used to check if a specified class has been defined?

class_exists

Which method of a DateTime object can be used to determine an amount of time between two dates or times?

diff

Which PHP function returns a string with all special HTML converted to the HTML entity?

htmlentities

Which PHP function convert some special characters into character entities?

htmlspecialchars

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

i

variable substitution is carried out by what process that converts a variable's value to a string?

interpolation

The $_SESSION variable for a session

is an associative array

Which PHP function can be used to determine if an object is an instance of a class?

is_a

While loops and for loops are often referred to as _____ structures.

iteration

A variable declared inside a PHP function would be considered a ____________ variable.

local

To create an object from a class named Cart that requires two arguments, you code

new Cart($arg1, $arg2)

Which PHP function returns the number of characters in the string?

strlen

When you create a DateInterval object, you pass it one argument that specifies one or more of the following:

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


Ensembles d'études connexes

PN NCLEX 6th Edition- Mental Health

View Set

ACUTE 2_Chapter 34: Care of Patients With Dysrrhythmias

View Set

SWE - chapter 3 :Agile software development

View Set