ServerSide Exam 2
You can use the __________ variable within a class to refer to the current object
$this
Which character is used before an argument to specify that the variable is being passed to a PHP function by reference?
&
__________ provide a way for a web application to store information in the user's web browser
Cookies
The diff() method of a DateTime object requires another DateTime object as its argument and returns a/an __________ object
DateInterval
If you create a function that passes an argument by reference, the function
can change the original variable without using a return statement
A static property or method is one that belongs to a/an
class
A/an __________ defines the methods and properties of an object
class
Which PHP function can be used to check if a specified class has been defined?
class_exists()
A/an __________ is a special method within a class that is executed when a new object is created from the class
constructor
Which PHP function returns the number of elements in an array?
count()
Which of the following is a method of a DateTime object that can be used to determine an amount of time between two dates or times?
diff()
A variable declared inside a PHP function would be considered a __________ variable
local
If you declare a variable within a function, the variable has __________ scope
local
When you code a function that includes a variadic parameter, that parameter
must be coded last
A __________ is a special type of array that implements a first-in, first-out collection of values
queue
A/an __________ is a type of array in which the first element added is the first to be removed
queue
A timestamp stores the number of __________ since midnight on January 1, 1970 GMT
seconds
Which PHP function can be used to end a session?
session_destroy()
What type of function can accept a variable number of arguments?
variadic
To get the value of a cookie, you can use the autoglobal __________ variable
$_COOKIE
Once a session is started, which superglobal variable can be used to get and set the user's data for a session?
$_SESSION
A session ID lets PHP associate a user with the data that's stored in the related
$_SESSION variable
If a request is not sent, a session will end by default after __________ have passed
24 minutes
The use of __________ objects resolves the Y2K38 problem because the upper limits of dates and times are essentially removed
DateTime
What is the default name of a session cookie in PHP?
PHPSESSID
Which of the following is NOT true about type declarations?
They were introduced with PHP 7
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
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 statements about an array of arrays is true?
You can use both for loops and foreach loops to work with an array of arrays
When you use session tracking, each HTTP request includes
a cookie that stores the session ID
To delete a cookie, you set the cookie's value to an empty string and its expiration date to
a time in the past
To create a DateTime object based on the date and time you specify, you use a/an __________ template
absolute
Which of the following is a method of a DateTime object that can be used to add a period of time to the date?
add()
In PHP, function name duplications are likely to occur because
all functions have global scope
The $_SESSION variable for a session is
an associative array
Which type of PHP function does not have a name?
anonymous
When you call a function, you can pass __________ as values that correspond to the parameters of the function
arguments
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 returns the key for an element in an associative array if the specified value exists?
array_search()
Which of the following is a PHP function that returns the sum of the elements in an array?
array_sum()
The easiest way to add the values in an array is to use the
array_sum() function
What type of function can only evaluate a single expression?
arrow
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
When you pass arguments to a function by name, the named arguments
can appear anywhere in the argument list
Which of the following functions would you use to define a constant that stores an array in PHP 7.0 or later?
define()
To create a default value for a parameter in the parameter list of a function, you code a/an __________ after the parameter name followed by the default value
equal operator
You can use the __________ operator with PHP 7 or later to compare two values
equal, identity, spaceship
A subclass can __________ the superclass by adding new properties and methods
extend
A function library is just a/an __________ that contains one or more functions
file
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
In PHP, all functions have __________ scope
global
Which of the following keywords can you use to refer to a variable that's declared outside the function?
global
When you use a for loop to process the values in a regular array, the counter value can be used as the __________ for each element in the array
index
A cookie is a
name/value pair that's stored in the user's browser
To create a DateTime object for the current date, you use the __________ keyword and pass no arguments to the constructor
new
To create an object from a class, you code the __________ keyword followed by the class name and an argument list
new
If you use the unset() function to delete the value of an element in an array, the value is replaced by a/an __________, thus creating a gap in the array
null value
To call one of the methods for an object, you code the object name followed by __________ and the method name
object access modifier (->)
When you start a new class from a parent class, you can __________ a method of the parent class
override
When creating functions, you can include __________ that are located inside parentheses after the function name
parameters
A cookie that does not expire when the user closes his or her browser is a(n) __________ cookie
persistent
Which of the following are variables that store the data for a class?
properties
__________ properties are inherited but not accessible outside the class
protected
To prevent other classes from directly accessing the properties of a class, you can code them as private. Then you can code
public methods to set and get their values
When you use inheritance, the new class starts with the __________ properties and methods
public, protected
To create a DateTime object based on an offset you specify to the current date and time, you use a/an __________ template
relative
Within a function, you can end the function and pass the result back to the calling statement by coding a/an __________ statement
return
Which of the following types can you use with function parameters?
scalar, nullable, union
Which term describes locations in the code that have access to a variable?
scope
A session begins when a browser makes its first request to a page that executes the __________ function
session_start()
Which PHP function is used to resume a previous session?
session_start()
Which of the following functions can you use to modify a DateTime object?
setDate(), setTime(), modify()
Which PHP function is used to create a cookie?
setcookie()
Which of the following is a PHP function that shuffles the values in an array in a random order?
shuffle()
Which of the following is a PHP function for sorting arrays?
sort(), rsort(), krsort()
To create a function with a variable number of parameters, you can use the PHP __________ operator
spread
A __________ is a special type of array that implements a last-in, first-out collection of values
stack
Gaps can be introduced into an array in all of the ways that follow, except one. Which one is it?
store an empty value in an array
Which of the following is considered a scalar value?
string literal, numeric literal, Boolean value
A/An __________ is an integer that represents a date and time as the number of seconds since midnight, January 1, 1970
timestamp
Which one of the following can the spread operator NOT be used for?
to merge two or more arrays into a single array, to merge arrays and individual values into a single array, to pass an array of values to a function that expects to receive individual values
To refer to an element in a rectangular array, you need to use __________ indexes
two
To declare that a parameter can have more than one type, you can use a/an
union type
To avoid the duplication of function names, you can
use namespaces
By default, all arguments passed to PHP functions are passed by
value
A foreach loop can be used to get which of the following for each element in an associative array?
value, position
A function that can accept a variable number of arguments is called a/an __________ function
variadic
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
Timestamps will encounter a/an _______ problem if they are not converted to DateTime objects
Y2K38
Which PHP function returns an array with the elements of two or more arrays in one array?
array_merge()
Which of the following functions removes the next element in a LIFO array (also known as a stack)?
array_pop()
Which of the following is NOT a valid technique for passing an argument to a function?
by option
A method is a/an __________ that's coded within a class
function
To create a persistent cookie, you set the __________ parameter of the setcookie() function
$expire
Which of the following is a parameter of the setcookie() function?
$name, $value, $expire
Which parameter of the session_set_cookie_params() function can be set so the cookie is only available on an HTTPS connection?
$secure
