|
Chapter 5
Working with Data
In This Chapter
Understanding data types
Performing arithmetic
Manipulating character strings
Using dates and times
V
ariables can store data of different types, and different types of data can
do different things. For example, you can add variables whose values are
numbers (1 + 2), but adding variables whose values are characters (a + b)
doesn’t make much sense. In this chapter, you find out what data types PHP
can handle and how you can use them.
Understanding Data Types
You can store the following simple types of data in PHP variables:
Integer:A whole number (no fractions), such as –43, 0, 1, 27, or 5438.
The range of integers that is allowed varies, depending on your oper-
ating system, but in general, you can usually use any number from
–2 billion up to +2 billion.
Floating point number:A number (usually not a whole number) that
includes decimal places, such as 5.24 or 123.456789. This is often called
a real numberor a float.
Character string:A series of single characters, such as
hello
. There is
no practical limit on the length of a string.
Boolean:A TRUE or FALSE value. See the nearby sidebar for more
information.
|