Answers to Chapter 5

  1. "How many times should srand() be called" The answer is "b": calling it more or less than once per script will affect the randomness.

  2. "To safely pass an array over the web, what is the correct sequence of function calls" You should really be looking for "d".

  3. "When passing a negative "step" parameter to the range() function, the initial value must always be larger than the end value: true or false" Another trick question - I do apologise! You can't specify a negative step parameter.

  4. "To randomise the order of an array, which function(s) can you use" The answer is "a": shuffle().

  5. "Which of the following statements are true about arrays that have a hole" The answer is "a": use foreach. You might have thought "b" was correct, but array_values() irretrievably destroys the existing keys, which is often a bad thing!


Next chapter: Answers to Chapter 6 >>

Previous chapter: Answers to Chapter 4

Jump to:


Home: Table of Contents

Follow us on or Twitter

Username:   Password:
Create Account | About TuxRadar