Chapter 14 Answers
The most noticeable difference between Boolean values in PHP and JavaScript is that PHP recognizes the keywords
TRUE
,true
,FALSE
, andfalse
, whereas onlytrue
andfalse
are supported in JavaScript. Additionally, in PHP,TRUE
has a value of1
andFALSE
isNULL
; in JavaScript they are represented bytrue
andfalse
, which can be returned as string values.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 surround the parts of an expression to be evaluated first with parentheses.
You use the identity operator when you wish to bypass JavaScriptâs automatic operand type changing.
The simplest forms of expressions are literals (such as numbers and strings) and variables, which simply evaluate to themselves.
The three conditional statement types are
if
,switch
, and the?
operator.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.Loops using
for
statements are more powerful thanwhile
loops because they support two additional parameters to control loop handling.The
with
statement takes an object as its parameter. Using ...
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.