Hudzilla.org - the homepage of Paul Hudson
Contents > Introducing PHP Wish List | Report Bug | About Me ]

2.10     Exercises

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

  1. Which of these statements is true about PHP 5?

    • a) Require and include are the same

    • b) Require includes files whether or not the line is executed

    • c) Require exits the script if it cannot find the file to include

    • d) None of the above

  2. Which of the following is not a valid way to start a PHP comment?

    • a) //

    • b) ##

    • c) /*

    • d) None of the above

  3. PEAR is...

    • a) A tasty fruit

    • b) The PHP Extended Assignment Repository

    • c) The PHP Extension and Application Repository

  4. Heredoc syntax is...

    • a) A way to define strings without worrying about quotation marks

    • b) A automatic documentation tool for PHP

    • c) The opposite of theredoc syntax

  5. Mixed-mode processing is...

    • a) The act of outputting HTML and pictures at the same time

    • b) The act of entering and exiting PHP processing mode several times

    • c) Impossible in PHP

  6. Using switch/case rather than multiple if statements is...

    • a) Faster

    • b) Easier to read

    • c) Both a) and b)

    • d) None of the above

  7. Escape sequences are the fastest way to exit your script: true or false?





<< 2.9 Summary   2.11 Further reading >>
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
A PHP Learner - 29 Aug 2008

i hv to learn php very fast to be able to complete my final sem proj..this online book has surely helped me get the basic idea cleared.

A PHP User - 29 Aug 2008

Actually it's 2d. When you start things off with a #, anything after it is considered a comment. So, in essence, ## is valid too. BUT, if you want to stay within the context of what the book states, then # was the correct way to start it off, and 2b would be correct.

jlx - 29 Aug 2008

Sorry, it is

1c

If you find that you write a script that absolutely needs a particular file to be included, PHP also has the require keyword, which, if called on a file that does not exist, will halt script execution with a fatal error.

A PHP User - 29 Aug 2008

1)d
2)b
3)c
4)a
5)b
6)c
7)false

A PHP User - 29 Aug 2008

so far it is a great book, I already learned a lot from it. I have tried to learn php before but I didnt succeeded because of the crappy stuff I was trying to learn it from. But now i have this great book. :D

Blue - 29 Aug 2008

There are answers to all the exercises in this book, have a look at the contents table (24.something I believe),
good luck.

A PHP User[x] - 29 Aug 2008

The opposite of theredoc syntax...
lmao
Oh ...what have I been missing all this time ?

GrafxLvr - 29 Aug 2008

I beg to differ... I think if you've read the material, and understand it, you would automatically know what the answer is; no questions asked. If you have doubts on a question, having a PHP script tell you you're wrong will not help your "learning" experience. Going back and re-reading the material, now that, that will help the learning experience.

Anyhow... This is an amazing virtual book...

A PHP User - 29 Aug 2008

Like the others "said"

A PHP User - 29 Aug 2008

Like the other side, since you are the PHP expert, im sure you'll have no problem coding the interactive form. :P

A PHP User - 29 Aug 2008

Would help if somewhere you had a section for the answers to the questions in the Exercises. =D But that's just IMO, anyway if you already have a section for the answers I'm sorry, since I hadn't seen it yet (because I started at the introduction and did not bother to glance at the table of contents, pretty much since I'm a total newbie to this).

Shantuk123@lycos.com - 29 Aug 2008

It'd be great if these exercises were interactive forms so you could pick your answers on the screen and get immediate feedback. So if you are right you know it, if not then you can try again.



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 six?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow