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 14 Answers

  1. The most noticeable difference between Boolean values in PHP and JavaScript is that PHP recognizes the keywords TRUE, true, FALSE, and false, whereas only true and false are supported in JavaScript. Additionally, in PHP, TRUE has a value of 1 and FALSE is NULL; in JavaScript they are represented by true and false, which can be returned as string values.

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

  3. The best way to force your own operator precedence is to surround the parts of an expression to be evaluated first with parentheses.

  4. You use the identity operator when you wish to bypass JavaScript’s automatic operand type changing.

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

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

  7. 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.

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

  9. The with statement takes an object as its parameter. Using ...

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