All data stored by PHP is put into one of eight different types of buckets, technically called data types. The data type determines what operations can be carried out on that piece of data.
Four of the data types are scalar–they support only a single value. These are integer (a whole number), float (a number with a decimal point), string (a sequence of symbols) and boolean (0 or 1).
PHP also has two compound data types. One is an array, or a bounded collection of multiple values. The other is an object, or a collection of data that also contains properties and methods. Finally, PHP has two special data types. One is a resource, which is a reference to some external data source. The other, null, has only one value, null.
PHP is a loosely typed language, meaning the variables do not need to have their data types defined before they are used. If you code $sample = 4.5; then PHP will assume the the $sample variable is a floating point data type. It is totally up to you to make sure that you pass the correct data type to any operation (i.e. don’t ask PHP to multiply two text strings).
That said, PHP offers some tools to help get a handle on all your loose data types. PHP’s gettype() function can let you know what type of data type the provided variable is, i.e. gettype( $sample ). You can also change a data type with PHP settype(), i.e. settype ( $sample, “integer”) will return the value of 4. PHP tries to preserve as much of the original value as possible during the conversion process.
Finally, you can set a variable’s type even before it is assigned a value. This is called type casting. Here you place the name of the data type, in parenthesis, before the name of the variable. So “(float) $sample = 4.5″ will ensure that the $sample variable will be a floating point data type.
From the book
All mistakes are my own, however…-Joab Jackson