"To delete a variable, what function do you use" Unset(), of course! Answer "b" is correct.
"To uppercase the first letter in a string, what function do you use" Answer "d" is correct: ucfirst() is the function to use.
"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.
"Which of the following statements are true about recursive functions" A recursive function is simply one that calls itself, therefore answer "a" is correct.
"Regular expressions should be used whenever possible : true or false" Rubbish: false.
"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.
"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".
Want to learn PHP 7?
Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!
Next chapter: Answers to Chapter 5 >>
Previous chapter: Answers to Chapter 3
Home: Table of Contents
Copyright ©2015 Paul Hudson. Follow me: @twostraws.