PHP defines 8 different variable types. These are outlined here for your quick reference. Be familiar with each of the different types and how they may be used in your programming.

Scalar Types

Data Type Description
Boolean A logical datatype with only two distinct possible values: true and false
Integer A numeric value in the form of a whole number. A whole number has no fractional parts (or decimal point).
Float A floating point or real number. This number is in the format -35.2357
String A string is an ordered sequence of characters. A character may be any unicode character your computer may display.

Compound Types

Data Type Description
Array An array is an indexed list of items. In PHP, arrays may be indexed by number (a regular array) or by strings (an associative array)
Object An object is an instance of a class that contains member variables and methods. Data and method implementations are encapsulated and hidden from the user to simplify development and maintain the integrity of the system.

Special Types

Data Type Description
Resource A special operating system specific piece of data. This may correspond to a database connection, an image resource or a filesystem context
Null Null is a special value that is assigned to a variable to indicate that the variable holds no valid data.
 
datatypes.txt · Last modified: Apr 18, 2008 - 2:00pm (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki