O'Reilly logo

Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition by Robin Nixon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4 Answers

  1. In PHP, TRUE represents the value 1 and FALSE represents NULL, which can be thought of as “nothing” and is output as the empty string.

  2. The simplest forms of expressions are literals (such as numbers and strings) and variables, which simply evaluate to themselves.

  3. The difference between unary, binary, and ternary operators is the number of operands each requires (one, two, and three, respectively).

  4. The best way to force your own operator precedence is to place parentheses around subexpressions to which you wish to give high precedence.

  5. Operator associativity refers to the direction of processing (left to right or right to left).

  6. You use the identity operator when you wish to bypass PHP’s automatic operand type changing (also called type casting).

  7. The three conditional statement types are if, switch, and the ? operator.

  8. To skip the current iteration of a loop and move on to the next one, use a continue statement.

  9. Loops using for statements are more powerful than while loops because they support two additional parameters to control the loop handling.

  10. Most conditional expressions in if and while statements are literal (or Boolean) and therefore trigger execution when they evaluate to TRUE. Numeric expressions trigger execution when they evaluate to a nonzero value. String expressions trigger execution when they evaluate to a nonempty string. A NULL value is evaluated as false and therefore does not trigger execution.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required