Docsity

Quiz Part 2 - Client and Server-Side Programming | CSCI 2910, Quizzes of Computer Science

Toggle sidebar
bg1
CSCI 2910 PHP Part 2 Quiz Name: ________________________________
Spring 2006
1. The PHP keyword "static" is used to:
a.) make the PHP code of your scripts visible to the client like JavaScript.
b.) declare global variables visible to all other functions.
c.) declare a special data type used for random numbers.
d.) declare a variable that maintains its value, but is visible only within its function.
e.) create an array of fixed length.
2. True or false: It is possible to use an index other than integer values starting at 0.
3. True or false: It is possible to declare an array where the elements are of mixed data types.
4. True or false: Because of the odd indices allowed by PHP, all element initializations must have an
index, e.g., you cannot define a new array element with $array[] = 45.
Use the following array declaration for the next three problems.
$numbers = array(0=>23, "second"=>45, 3=>13, "fourth"=>96);
5. Assume an additional element were added to the array $numbers with the code $numbers[1]=9;
After which element would it be included in the array?
a.) 0 b.) "second" c.) 3 d.) "fourth" e.) Can't be predicted
6. Fix the code below to ensure that it will not print "Array element 3 is Array[3]" and instead print "Array
element 3 is 13"
print "Array element 3 is $numbers[2] ";
7. The code print $numbers[1]; will print:
a.) 23 b.) 45 c.) 13 d.) 96 e.) 1 f.) null (not defined)
Use the following code for the next two problems.
foreach ($a as $b => $c) print $b;
8. Within the foreach loop, which variable name represents the current array index being evaluated?
a.) $a b.) $b c.) $c
9. Within the foreach loop, which variable name represents the current array element being evaluated?
a.) $a b.) $b c.) $c
10. Which "printf" specifier is used to format an element as binary?
a.) %c b.) %d c.) %u d.) %x e.) %o f.) %f g.) %b
11. In the space below, write the PHP code to initialize a 2x2 array representing the matrix 1 2
3 4

Partial preview of the text

Download Quiz Part 2 - Client and Server-Side Programming | CSCI 2910 and more Quizzes Computer Science in PDF only on Docsity!

CSCI 2910 PHP Part 2 Quiz Name: ________________________________ Spring 2006

  1. The PHP keyword "static" is used to: a.) make the PHP code of your scripts visible to the client like JavaScript. b.) declare global variables visible to all other functions. c.) declare a special data type used for random numbers. d.) declare a variable that maintains its value, but is visible only within its function. e.) create an array of fixed length.
  2. True or false: It is possible to use an index other than integer values starting at 0.
  3. True or false: It is possible to declare an array where the elements are of mixed data types.
  4. True or false: Because of the odd indices allowed by PHP, all element initializations must have an index, e.g., you cannot define a new array element with $array[] = 45. Use the following array declaration for the next three problems. $numbers = array(0=>23, "second"=>45, 3=>13, "fourth"=>96);
  5. Assume an additional element were added to the array $numbers with the code $numbers[1]=9; After which element would it be included in the array? a.) 0 b.) "second" c.) 3 d.) "fourth" e.) Can't be predicted
  6. Fix the code below to ensure that it will not print "Array element 3 is Array[3]" and instead print "Array element 3 is 13" print "Array element 3 is $numbers[2] ";
  7. The code print $numbers[1]; will print: a.) 23 b.) 45 c.) 13 d.) 96 e.) 1 f.) null (not defined)

Use the following code for the next two problems. foreach ($a as $b => $c) print $b;

  1. Within the foreach loop, which variable name represents the current array index being evaluated? a.) $a b.) $b c.) $c
  2. Within the foreach loop, which variable name represents the current array element being evaluated? a.) $a b.) $b c.) $c
  3. Which "printf" specifier is used to format an element as binary? a.) %c b.) %d c.) %u d.) %x e.) %o f.) %f g.) %b
  4. In the space below, write the PHP code to initialize a 2x2 array representing the matrix (^1 )

3 4