True or False
PHP considers some values to be equivalent to true
, and others equivalent to false
. Most numbers are true (e.g., 1, 59, 1,203,391,462), but 0, 0.0, 0.00000 are all false.
Nearly any string with a value in it is considered to be true, so "a," "193" (an integer inside a string), and "This is a test" are all true. However, an empty string ""and "0" are both false. Confusingly, though, "0.0" is true, as is "0.0000."
Get PHP in a Nutshell 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.