Hudzilla.org - the homepage of Paul Hudson
Contents > Simple variables and operators Wish List | Report Bug | About Me ]

3.14     Exercises

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

  1. Which of the following are not valid variables:

    • a) $blah

    • b) $f11

    • c) $_11f

    • d) $11f

    • e) None of the above

  2. What will $foo be set to in this expression: $foo = "wombat" * 2?

  3. What will $bar be set to in this expression: $bar = 5 * 5 + 5?

  4. What does the =< operator do?

  5. How does OR differ from || ?

  6. The superglobal array variables are accessible...

    • a) Only outside functions

    • b) Only inside functions

    • c) Anywhere except in classes

    • d) Anywhere, as long as they are defined GLOBAL

    • e) None of the above





<< 3.13 Summary   3.15 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
jlx - 30 Aug 2008

1)d
2)0
3)30
4)parse error
5)|| has a higher priority
6)e

Steve - 30 Aug 2008

I agree with Alex. This is where many programming books and tutorials fall short, in my (very limited) experience. Maybe this comes later in the book? As a newbie, I find that the concepts are explained quite well for the most part (the comments have been helpful) but I don't know what to do with the information yet.

Alex - 30 Aug 2008

I think it would be much much better if the exercises were actually " write a script that does X( say a calculator script for example) using the infomation you have learnt so far re-reading any parts if needed" with like say 3-4 different exercises that used most of what you learnt so far that way you have to think for yourself how you should write the script and it reinforces your knowledge on php but also its good when your scripts work which makes you want to focus more on php and learn more of the great features it has.

cast3r - 30 Aug 2008

hehe, 4th is tricky heheheh i like confusing questions :)

A PHP User - 30 Aug 2008

The answers to the exercises are in chapter 24: "Answers to Exercises".

A PHP User - 30 Aug 2008

But people would still like to know if they are right. If you are practicing the wrong thing you aren't learning!

Basil Rhanedear - 30 Aug 2008

I think its good that you force people to do it themselves, as actually doing it is a great way to learn.

lars - 30 Aug 2008

Yearh. a result list would be great :)

Jordan - 30 Aug 2008

A way to find out the answers directly would be helpful for these exercises.

Thanks for this great guide :D



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


Top-right shadow
 
Bottom-left shadow Bottom shadow