Answers to Chapter 3

  1. "Which of the following are not valid variables", the answer is "d" - variables may not start with a number.

  2. "What will $foo be set to in this expression: $foo = "wombat" * 2 The answer is 0, because a string multiplied by an integer will yield 0.

  3. "What will $bar be set to in this expression: $bar = 5 * 5 + 5 The answer is 30, because multiplication takes precedence over addition, meaning that the 5 * 5 is done first, giving 25, then 5 is added, giving 30.

  4. "What does the =< operator do?" The answer is: terminate PHP. This is because there is a <= operator meaning "less than or equal to", but there is no =< operator, so PHP will exit saying, "parse error, unexpected '<'. Trick question - sorry!

  5. "How does OR different from ||" - || is a higher priority operator than OR, meaning it gets evaluated sooner.

  6. "The superglobal array variables are accessible..." can be answered only by "e". Well, if you were listening, that is!

 

Next chapter: Answers to Chapter 4 >>

Previous chapter: Answers to Chapter 2

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar