Answers to Chapter 4

  1. "To delete a variable, what function do you use" Unset(), of course! Answer "b" is correct.

  2. "To uppercase the first letter in a string, what function do you use" Answer "d" is correct: ucfirst() is the function to use.

  3. "What does the dl() function do, and what is the major disadvantage to using it" The dl() function loads an extension dynamically, but that extension gets unloaded soon after therefore it is very slow and should be avoided.

  4. "Which of the following statements are true about recursive functions" A recursive function is simply one that calls itself, therefore answer "a" is correct.

  5. "Regular expressions should be used whenever possible : true or false" Rubbish: false.

  6. "You always need to use addslashes() on variables before inserting them into a database: true or false" False, but it was a bit of a trick question. Yes, you should make sure your input is escaped, but when working with a database specifically it's better to use mysqli_real_escape_string() or similar to do the right job.

  7. "Using register_shutdown_function(), you can register as many shutdown functions as you want: true or false?" Although there may well be a very high limit, it's not one worth worrying about: the answer is "true".

 

Next chapter: Answers to Chapter 5 >>

Previous chapter: Answers to Chapter 3

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.