PHP

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Timestamp

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

queue

A ________________ is a special type of array that implements a first-in, first-out collection of values.

Stack

A ________________ is a special type of array that implements a last-in, first-out collection of values.

encapsulation

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

extend

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

expression

A switch statement in PHP start by evaluating a switch ________________.

Seconds

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

local

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

local

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

func_get_args function

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

associative

An array that uses strings as indexes in PHP is known as a(n) ________________ array.

Selection

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

Value

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

3

How many operands does a ternary operator have?

A count of the number of matches and an array that contains all of the matches

If a match is found in a global search for a regular expression, the function returns

An array of the substrings that are created by removing the matches

If a match is found when the preg_split function is executed, it returns

24 Minutes

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

Dec. 25, 2017

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

12/25/2017 12:00 AM

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

12/25/17

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

December 25, 2017

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

can change the original variable without using a return statement

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

throw new Exception("Validation error") ;

If you want to create an exception within a data-validation function and throw it to the statement that called the function, you code

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

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.

round()

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

Name

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?

$_SESSION

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

can be used to completely validate some types of user entries

Regular expressions

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

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:

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

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:

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

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:

is an associative array

The $_SESSION variable for a session

the array_sum() function

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

/^\d{5}$/

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

Y2K38

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

Use namespaces

To avoid the duplication of function names, you can

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

To create a DateTime object that represents a due date that's 90 days after the current date, you use the following code:

function randomize(&$parm1, $parm2 = 5) {

To create a function named randomize that has one parameter that has a default value of 5 and one required parameter that's passed by reference, you start the function like this:

new Cart($arg1, $arg2)

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

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

To delete a cookie, you

$_COOKIE

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

public methods to set and get their values

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

$category->categoryName

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

interpolation

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

PHPSESSID

What is the default name of a session cookie in PHP?

;

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

Brick Tamland

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

141.95|212.95|312.95|10.95|

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] . "|"; }

override the inherited methods

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

parameters

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

arguments

When you call a function, you can pass ________________ as values that correspond with the parameters of the function.

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

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

a cookie that stores the session ID

When you use session tracking, each HTTP request includes

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

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

the starting position of the substring

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

class_exists()

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

isset

Which PHP function can be used to determine if a checkbox is checked?

is_a()

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

session_destroy()

Which PHP function can be used to end a session?

setcookie()

Which PHP function is used to create a cookie?

htmlentities()

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

array_merge

Which PHP function returns an array with the elements of two or more arrays in one array?

strlen()

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

count

Which PHP function returns the number of elements in an array?

method

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

$

Which character is used to separate parameters that are appended to a URL?

?

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

\B

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

$

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

"02/34/1968"

Which date string matches the pattern that follows? /^[01]?\d\/[0-3]\d\/\d{4}$/

preg_match

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

diff()

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

By reference

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

Properties

Which of the following are variables that store the data for a class?

/c

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

sort(), rsort(), krsort() All of these

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

array_count_values

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

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_sum()

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

shuffle()

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

callback

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

Closure

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

$name, $value, $expire

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

constructor

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

all of these-Single/double quotes and heredoc

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

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

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

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

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

continue

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

/r

Which of the following will match a carriage return in a PHP regular expression?

\W

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

\d

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

\w

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

$secure

Which parameter of the session_set_cookie_params can be set so the cookie is only available on an HTTPS connection?

Scope

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

scope

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

anonymous

Which type of PHP function does not have a name?

checkbox

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?

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

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

cookies

________________ 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.


Set pelajaran terkait

Biochemistry - Chapter 30: Amino Acid Degradation and the Urea Cycle

View Set

COSC Microsoft Word Module Quizzes

View Set

30: Government Intervention in the Functioning of Markets

View Set

Chapter 6 -- Development in Infancy

View Set

Finance Final Exam (Ch 7, 8, 12, 13 Concepts)

View Set

Personality and Personal Growth ch 4 & 5 Psyc216

View Set

Quoting, Paraphrasing, Summary, and Incorporating In-text Citations

View Set

Chapter 1 - Personal Finance Basics and the Time Value of Money

View Set