PHP
Which date string matches the pattern that follows? /^[01]?\d\/[0-3]\d\/\d{4}$/
"02/34/1968"
Which character is used to separate parameters that are appended to a URL?
$
Which character is used to signify the end of the string in a PHP regular expression?
$
To get the value of a cookie, you can use the autoglobal ______________ variable.
$_COOKIE
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);
To refer to a public property named categoryName for an object that's referenced by $category, you code
$category->categoryName
To create a DateTime object that represents a due date that's 90 days after the current date, you use the following code:
$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:
$i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+2);
Given the code that follows, $employees = 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"];
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];
Which of the following is a parameter of the setcookie function?
$name, $value, $expire
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;
To round and format the value of a variable named $number to 3 decimal places and store it in a variable named $number_formatted, you code:
$number_formatted = number_format($number, 3);
Which parameter of the session_set_cookie_params can be set so the cookie is only available on an HTTPS connection?
$secure
Which character is used before an argument to specify that the variable is being passed to a PHP function by reference?
&
What extensions of a filename is typically associated with a static web page?
.html
Which function can be used to forward a request from one PHP file to another?
.include()
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 of the following will match a carriage return in a PHP regular expression?
/r
If the date is December 25, 2017, what output would be produced by the following code? echo date('n/j/y');
12/25/17
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/2017 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
If a PHP array contains 7 elements, what is the number of the index of the seventh element?
6
What modifier can be added to the end of a regular expression in PHP to make it case insensitive?
;
Which character is used to separate the original URL from the parameters that are appended to it?
?
A request and response for a file are made by...
A Client and a server
Doesn't appear on the form but its data is sent to the server.
A Hidden Field
If a match is found in a global search for a regular expression, the function returns
A count of the number of matches and an array that contains all of the matches
when you use the header() func. to redirect a request.
A response is returned to the browser that tells it to request another page
When you create a delete statement, you usually need to include....
A where clause
A join that returns records from related tables only if their related fields match is called....
An Inner Join
If a match is found when the preg_split function is executed, it returns
An array of the substrings that are created by removing the matches
_____ are used in PHP to perform math calculations, such as addition.
Arithmetic Operators
To make it easier to enter names into your code, netbeans provides a feature known as...
Auto-completion
A ________ value is a value of true or false.
Boolean
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
Which method of passing a variable allows the function to change the value of the variable?
By reference
A PHP variable name is ________.
Case-Sensitive
Which type of input element should be used on a form when the user can select more than one of the options?
Check box
A web application is a type of ______.
Client / Server Application
Which of the following is a nested function that has access to the outer function's local variables?
Closure
A ______ contains a value that does not change during the course of program execution.
Constant
A switch statement in PHP is often useful in the ________________ of an application that uses the MVC pattern.
Controller
Which of the following is not a common MySQL data type
DBL
The _____ for a MySQL connection specifies the host computer for the mysql database and the name of the database.
DSN Data Source Name
If the date is December 25, 2017, what output would be produced by the code below? echo date('M. d, Y');
Dec. 25, 2017
If the date is December 25, 2017, what output would be provided by the code below? echo date('F d, Y');
December 25, 2017
The equality operator consists of two _____ signs and performs a different function than the one performed by the assignment operator.
Equal
An ____ is an object that contains information about an error.
Exception
Which of the following is an object that contains information about an error that occurred?
Exception
What is the goal of testing an application before it is put into production?
Find all errors
The goal of testing is to _______.
Find all errors in the application
Which of the following can be used to get the data from an array that contains all rows of a result set?
For Each statement
The HTTP response for a dynamic web page is passed...
From the web server to the browser
Which method of the form appends values to the URL to pass data?
Get
Which type of SQL statement is used to assign user privileges in MySQL.
Grant
Which of the following is not a common MySQL Priviledge
Inset Table
A(n) _______ is a positive or negative number with no decimal places.
Integer
Variable substitution is carried out by what process that converts a variable's value to a string?
Interpolation
One reason for using the header() function is to redirect a request...
Is to have a PHP file run against itself.
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,
Which type of error is often most difficult to find and fix
Logic
Which attr. of a form element determines how the data is passed to a file.
Method
What does the acronym MVC stand for?
Model-View-Controller
Which optional attr of a select element allows the user to select more than one option in a list box?
Multiple
Which of these would not be considered a common syntax error in PHP?
Multiply by the wrong variable
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?
Name
Which of the following is a class used for errors thrown by the PDO library
PDI Exception
Which PHP class can be used to connect to a MySQL database
PDO
What is the default name of a session cookie in PHP?
PHPSESSID
When creating a func, _____ can be included in the parenthesis that follow the name.
Parameters
A cookie that does not expire when the user closes his or her browser is a(n) ________________ cookie.
Persistent
What does a relational DB use to uniquely ID each row in a table?
Primary Key
Which of the following are variables that store the data for a class?
Properties
The first part of a URL is called the _______.
Protocol
Which of the following is not a database server that can be used for dynamic web pages?
Python
Which of the following are coded patterns that you can use to search for matching patterns in text strings?
Regular Expressions
The type of error that does not violate syntax rules, but causes the PHP interpreter to display error messages _____.
Run Time Error
Which type of error does not violate the rules of PHP statements must be written but will cause the PHP interpreter to display errors?
RunTime
Which term describes locations in the code that have access to a variable?
Scope
A timestamp stores the number of _____ since midnight on January 1, 1970 GMT.
Seconds
Which HTML element is used to create a drop-down list?
Select
An if statement can be used to implement a ________________ structure.
Selection
How many data types are used by PHP?
Six
A ________________ is a special type of array that implements a last-in, first-out collection of values.
Stack
A list of functions or methods in the reverse order in which they were called is a(n)________________.
Stack Trace
Which of the following lists the functions in the reverse order in which they were called?
Stack Trace
Which type of error is considered the easiest to fix
Syntax
To deploy a PHP application on your own computer, you copy the application root directory to...
The HTDOCS directory of the Apache Server
Which of the following is NOT a benefit of using the MVC pattern for an application?
The app runs more efficiently
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"
When you use the MVC Pattern, the controller gets the HTTP requests and then directs the use of the file that represents...
The model and the view
A _____ is an integer that represents a date and time as the number of seconds since midnight, January 1, 1970.
Timestamp
To handle exceptions, first you code a ____ around any PHP statements that might throw an error.
Try Block
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.
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
To run a PHP application that has been deployed on your own computer, you can enter a URL in the address bar of a browser that...
Uses local host as the domain name
By default, all arguments passed to PHP functions are passed by ________________.
Value
Which of the following consists of the PHP and HTML files that represent the user interface of the application
View
The column def for a MySQL table may be used to determine all but one of the following?
What range of value the column may contain
Timestamps will encounter a(n) _____ problem if they are not converted to DateTime objects.
Y2K38
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 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
Which of the following will match any digit in a PHP regular expression?
\d
Which of the following will match a tab in a PHP regular expression?
\t
Which of the following will match any letter, number, or underscore in a PHP regular expression?
\w
Which character is used to signify the beginning of the string in a PHP regular expression?
^
Consider the following code example: $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.'); } If $due_date contains a DateTime object, $due_date_diff will contain
a DateInterval object
When you use session tracking, each HTTP request includes
a cookie that stores the session ID
Which of the following is a way to assign a string to a variable on PHP?
all of these-Single/double quotes and heredoc
Which type of PHP function does not have a name?
anonymous
When you call a function, you can pass ________________ as values that correspond with 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 is used to count the number of times each value in an array is used?
array_count_values()
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 a PHP function that returns the sum of the elements in an array?
array_sum()
An array that uses strings as indexes in PHP is known as a(n) ________________ array.
associative
To execute a prepared SQL statement, you can use the _____ and execute methods of the PDO statement object to set parameter values and execute the statement
bind value
Which of the following is a function that is passed as an argument to another function?
callback
Regular expressions
can be used to completely validate some types of user entries
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 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?
checkbox
Which PHP function can be used to check if a specified class has been defined?
class_exists()
Which of the following is a special method executed when a new object is created from a class?
constructor
Which of the following statements will restart the execution of a loop?
continue
________________ 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
Which PHP function returns the number of elements in an array?
count
Which method of a DateTime object can be used to determine an amount of time between two dates or times?
diff()
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
display any HTML tags entered by the user instead of processing them
A hidden field
doesn't appear on the form but its data is sent to the server
A simple way to trace the execution of an application is to insert _____ statements at appropriate points with the code.
echo
A fundamental concept of object-oriented programming that groups related data and functionality in a class is called ____________________.
encapsulation
A switch statement in PHP start by evaluating a switch ________________.
expression
A subclass can ____________ the superclass by adding new properties and methods.
extend
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
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:
function randomize(&$parm1, $parm2 = 5) {
To get the message that's related to an exception, you use the
getMessage method of the exception object
Which function may be used to redirect a request to another URL?
header()
Which PHP function returns a string with all special HTML converted to the HTML entity?
htmlentities()
Which PHP function converts 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()
Which PHP function can be used to determine if a checkbox is checked?
isset
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.
local
Which attribute of a form element determines how the data is passed to a file?
method
Which of the following is a PHP function used to get random numbers?
mt_rand
Which optional attribute of a select element allows the user to select more than one option in a list box?
multiple
Radio buttons in a group all have the same ______ value..
name
Which keyword is used to create an object from a class in PHP?
new
To create an object from a class named Cart that requires two arguments, you code
new Cart($arg1, $arg2)
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 function searches for a regular expression in a string and returns 1 if the pattern is found?
preg_match()
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"
A ________________ is a special type of array that implements a first-in, first-out collection of values.
queue
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
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 PHP function can be used to end a session?
session_destroy()
Which PHP function is used to start a new session or resume a previous session?
session_start
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 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() All of these
A list of functions or methods in the reverse order in which they were called is a(n)________________.
stack trace
When HTML was first developed, web pages were typically _______.
static
Gaps can be introduced into an array in all of the ways that follow, exept 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=>all of these
Which PHP function returns the number of characters in the string?
strlen
Which PHP function returns the number of characters in the string?
strlen()
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
If you want to create an exception within a data-validation function and throw it to the statement that called the function, you code
throw new Exception("Validation error") ;
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