Chapter 4 Answers
In PHP,
TRUE
represents the value1
andFALSE
representsNULL
, which can be thought of as ânothingâ and is output as the empty string.The simplest forms of expressions are literals (such as numbers and strings) and variables, which simply evaluate to themselves.
The difference between unary, binary, and ternary operators is the number of operands each requires (one, two, and three, respectively).
The best way to force your own operator precedence is to place parentheses around subexpressions to which you wish to give high precedence.
Operator associativity refers to the direction of processing (left to right or right to left).
You use the identity operator when you wish to bypass PHPâs automatic operand type changing (also called type casting).
The three conditional statement types are
if
,switch
, and the?
operator.To skip the current iteration of a loop and move on to the next one, use a
continue
statement.Loops using
for
statements are more powerful thanwhile
loops because they support two additional parameters to control the loop handling.Most conditional expressions in
if
andwhile
statements are literal (or Boolean) and therefore trigger execution when they evaluate toTRUE
. Numeric expressions trigger execution when they evaluate to a nonzero value. String expressions trigger execution when they evaluate to a nonempty string. ANULL
value is evaluated as false and therefore does not trigger execution.
Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.