Hudzilla.org - the homepage of Paul Hudson
Contents > Answers to Exercises Wish List | Report Bug | About Me ]

24.6     Answers to Chapter 7

This is NOT the latest copy of this book; click here for the latest version.

  1. "What is the reason that register_globals is disabled by default in PHP" Because it's massively insecure - it mixes up $_GET, $_POST, $_SESSION, and other variables without any way to tell where they came from.

  2. "Which of the following superglobals are not contained inside of $_REQUEST" The answer is "b", but it's a trick question: $_COOKIE is included in $_REQUEST, but $_COOKIES I just made up - sorry!

  3. "Give one advantage of using POST to send form data, and one advantage of using GET" There are a selection to choose from: POST is more secure ans allows more data to be sent. GET is easier to edit directly (for more advanced users) and also is remembered by browsers because it's just in the URL, whereas POST brings up messages like "Are you sure you want to resubmit this form?"

  4. "Why is the is_numeric() function a better choice for form validation than the is_int() function" Because all form data is sent as strings, and is_numeric() returns true if a variable is an integer or a string containing an integer.

  5. "Which PHP function will automatically strip any HTML tags out of a variable" Strip_tags(), of course.

  6. "Why might the CTYPE functions be the preferred method for data validation" They are capable of more advanced things, but do keep in mind they are less well-known than traditional validation techniques.

  7. "Client-side validation should be avoided at all times: true or false" The answer is "false", because it can help lower server resource usage. Of course, you should never rely on client-side validation to be working.





<< 24.5 Answers to Chapter 6   24.7 Answers to Chapter 8 >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is two plus zero?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow