PHP Variables
PHP Variables
You are not required to initialize a variable when you first declare it.
What value is assigned to the $ReturnValue variable in the statement $ReturnValue = 100 != 200;?
What value is assigned to the $ReturnValue variable in the statement $ReturnValue = !$x;, assuming
that $x has a value of TRUE?
String comparison operators and most string comparison functions compare individual characters
according to their ASCII value.
What function splits each character in a string into an array element? explode()
(b) sequence
(c) case
(d) logical
echo $names[1];
$rate = 0.1;
if ( ! is_numeric($rate) ) {
} else {
How many radio buttons from the following code can be selected at any given time?
(a) 0
(b) 1
(c) 2
(d) 3
Which PHP function returns an array with the elements of two or more arrays in one array?
(a) array_merge
(b) array_slice
(c) array_splice
(d) array_fill_both
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?
(a) checked
(b) value
(c) name
(d) id
$cart = array();
$item = array();
$item['itemCode'] = 123;
$item['itemCost'] = 52.5;
$item['itemQuantity'] = 5;
$cart[] = $item;
To refer to the "itemCost" element in the associative array that's within the regular array, you would use
this code:
(a) $cart[0]['itemCost']
(b) $cart['itemCost'][0]
(c) $cart[$item['itemCost']]
(d) $item[$cart['itemCost']]
(a) case
(b) expression
(d) break
(a) is_checked
(b) boolean
(c) isset
(d) value
$statusCode = "403";
switch ( $statusCode ) {
case "200":
$message = "OK";
break;
case "403":
$message = "Forbidden";
break;
case "404":
break;
default:
break;
(a) OK
(b) Forbidden
echo $names[5];
What will the value of the $totals_string variable be after the following code is executed?
$totals[2] = 312.95;
$totals_string = "";
}
(a) 141.95|312.95|411|10.95|
(b) 141.95|212.95|312.95|10.95|
(c) 141.95|212.95|411|312.95|
(d) 10.95|
(a) select
(b) list
(c) drop-down
(d) input
Which attribute of a form element determines how the data is passed to a file?
(a) action
(b) method
(c) submit
(d) default
Suppose an array of country codes and country names is created with a statement like this:
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:
$last_name = $name[0];
$first_name = $name[1];
$last_name = $name[1];
$first_name = $name[0];
$last_name = $name[0];
$first_name = $name[1];
(d) $name = explode(', ', $name);
$last_name = $name[1];
$first_name = $name[0];
(a) count
(b) length
(c) max_index
(d) num_elements
An array that uses strings as indexes in PHP is known as a(n) ________________ array.
(a) non-numeric
(b) associative
(c) illegal
(d) imaginary
A hidden field
(c) doesn't appear on the form but its data is sent to the server
$age = 19;
$score = 750;
} else {
(a) <
(b) <=
(c) >
(a) list
(b) item
(c) option
(d) value
Which type of input element should be used on a form when the user can select only one of the
options?
(a) checkbox
(b) radio
(c) text
(d) submit
(a) len
(b) strlen
(c) countchars
(d) substr
Assume that the second radio button in the code below has been selected by the user. When you get
the value of that radio button, what will the value be?
(a) FedEx
(c) fedex
$employees = array();
$employee["age"] = 29;
While loops and for loops are often referred to as ________________ structures.
(a) selection
(b) sequence
(c) iteration
(d) ill-advised
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) L: 1, 3, 5, 7, 9,
(d) L: 1, 3, 5, 7
Which type of loop will always execute its code at least once?
(a) while
(b) do-while
(c) for
(d) for-in
(a) break
(b) continue
(c) for
(d) next
(a) break
(b) continue
(c) switch
(d) conditional