Primitives
Booleans
- To specify a boolean literal, use
either the keyword
TRUE or FALSE.
Both are case-insensitive.
- Avoid comparing a boolean to a
nonboolean, as the result will
often be different than expected - non-intutive; it converts the
nonboolean to a boolean, and then compares the two boolean values.
Examples
<?php
$mybool = true;
if ($mybool) {
echo "text\n";
}
?>
Integers
- Hexadecimal values are preceded by
0x
or 0X.
- Octal values are preceded by
0
(zero).
- PHP does not support unsigned integers.
- At present, integers are usually
32-bits (platform dependent).
- A value outside of the range of an
integer will be treated as
a float.
- Division of two integers yields a float
value.
Floating point numbers
12.34
.34
12.
1.2e3
7E-10
- aka "floats",
"doubles", "real numbers"
- Never compare two float values
(due to possible loss of
precision).