1.
A hidden field
A. 
A. appears on the form but its data is hidden
B. 
B. has data that is obscured by bullets or asterisks
C. 
C. doesn’t appear on the form but its data is sent to the server
D. 
D. appears on the form with its data grayed out
2.
Which of the following operators does NOT perform type coercion?
A. 
B. 
C. 
D. 
3.
Which type of loop will always execute its code at least once?
A. 
B. 
C. 
D. 
4.
Which of the following statements will restart the execution of a loop?
A. 
B. 
C. 
D. 
5.
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.';
}
A. 
B. 
Rate cannot be less than zero.
C. 
Rate cannot be greater than 20%.
D. 
6.
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.';
}
A. 
B. 
C. 
D. 
7.
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;
}
A. 
B. 
C. 
D. 
8.
What does $message contain after the following code executes?
$message = "L: ";
for ($i = 0; $i < 10; $i++ ) {
$message .= $i . ", ";
if ($i == 7) break;
}
A. 
L: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
B. 
L: 0, 1, 2, 3, 4, 5, 6, 7,
C. 
D. 
9.
When you use the substr function to extract a substring from a string, you need to at least pass an
argument that gives
A. 
The characters in the substring that you’re looking for
B. 
The starting position of the substring
C. 
The length of the substring
D. 
The separators for the substring
10.
A “natural” comparison of two values
A. 
B. 
C. 
Puts both “09” and “9” before “10”
D. 
Puts “10” before both “09” and “9”
11.
What is stored in $message by the code that follows?
$message = "The file is in \"C:\\My Documents\"";
A. 
The file is in C:\My Documents
B. 
B. The file is in "C:\My Documents"
C. 
C. The file is in C:\\My Documents\
D. 
The file is in "C:\\My Documents\"
12.
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:
A. 
$i = strpos($name, ', ');
$first_name = substr($name, 0, $i);
$last_name = substr($name, $i+1);
B. 
B. $i = strpos($name, ', ');
$first_name = substr($name, 0, $i);
$last_name = substr($name, $i+2);
C. 
C. $i = strpos($name, ', ');
$last_name = substr($name, 0, $i);
$first_name = substr($name, $i+1);
D. 
D. $i = strpos($name, ', ');
$last_name = substr($name, 0, $i);
$first_name = substr($name, $i+2);
13.
In 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?
A. 
B. 
B. if ((strtolower($a) < (strtolower($b))
C. 
C. if (strcomp($a, $b) < 1)
D. 
D. if (strnatcomp($a, $b) < 1)
14.
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:
A. 
A. $name = implode(', ', $name);
$last_name = $name[0];
$first_name = $name[1];
B. 
B. $name = implode(', ', $name);
$last_name = $name[1];
$first_name = $name[0];
C. 
C. $name = explode(', ', $name);
$last_name = $name[0];
$first_name = $name[1];
D. 
D. $name = explode(', ', $name);
$last_name = $name[1];
$first_name = $name[0];
15.
If you want to round a number within an arithmetic expression, which function should you use?
A. 
B. 
C. 
D. 
16.
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.
A. 
$number = mt_rand(1000,500000);
B. 
$number = mt_rand(100,50000);
$number *= 10;
C. 
$number = mt_rand(1,500);
$number *= 1000;
D. 
$number = mt_rand(10,5000);
$number *= 100;
17.
When you create a DateInterval object, you pass it one argument that specifies one or more of the following:
A. 
B. 
C. 
Years, months, days, hours, minutes, seconds
D. 
Years, months, weeks, days, hours, minutes, seconds
18.
Which of the following statements is NOT a valid way to create a timestamp named $birthdate that represents December 2, 1969?
A. 
$birthdate = mktime(0, 0, 0, 12, 2, 1969);
B. 
$birthdate = mktime(12, 2, 1969);
C. 
$birthdate = strtotime('1969-12-02');
D. 
$birthdate = strtotime('12/02/1969');
19.
To create a DateTime object that represents a due date that’s 90 days after the current date, you use the following code:
A. 
$days = new DateInterval('P90D');
$due_date = date();
$due_date = $due_date->add($days);
B. 
b.
$days = new DateInterval('P90D');
$due_date = new DateTime();
$due_date = $due_date->add($days);
(Technically, the book says that:
$due_date->add($checkout_length);
is the proper way to use the ->add() method without the $due_date = to the left.
C. 
$days = new DateInterval('P90D');
$due_date = date();
$due_date = $due_date + $days;
D. 
$days = new DateInterval('P90D');
$due_date = new DateTime();
$due_date = $due_date + $days;
20.
Code example 10-1
$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.');
}
14. (Refer to code example 10-1) If $due_date contains a DateTime object, $due_date_diff will contain
A. 
B. 
C. 
D. 
21.
Code example 10-1
$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.');
}
(Refer to code example 10-1) If $due_date contains a DateTime object for a date that comes 1 month and 7 days before the date stored in the $current_date variable, what will $overdue_message contain when this code finishes executing:
A. 
0 years, 1 months, and 7 days overdue.
B. 
-0 years, -1 months, and -7 days overdue.
C. 
1 month and 7 days overdue.
D. 
Overdue_message won’t be set because the if clause won’t be executed