Sunday, February 1, 2009

Data Types In PHP

Even though PHP is weakly typed, it uses the following eight data types

Integer: This is a whole number, such as 1, 25, 42, or 2006. Integers must not contain any commas or other punctuation as thousand-separators. You can also use hexadecimal numbers, which should be preceded by 0x (e.g., 0xFFFFFF, 0x000000).

Floating-point number: This is a number that contains a decimal point, such as 9.99, 98.6, or 2.1. Like integers, floating-point numbers must not contain thousandseparators.(This type is also referred to as float or double.)

String: A string is text of any length. It can be as short as zero characters (an empty string), and it has no upper limit.

Boolean: This type has only two values: true or false.

Array: An array is a variable that is capable of storing multiple values, although it may contain none at all (an empty array). Arrays can hold any data type, including other arrays. An array of arrays is called a multidimensional array.

Object: PHP has powerful object-oriented capabilities, which are mainly of interest to advanced users. Objects are used when connecting to a database with the MySQL Improved extension or PHP Data Objects (PDO).

Resource: When PHP connects to an external data source, such as a file or database,it stores a reference to it as a resource.

NULL: This is a special data type that indicates that a variable has no value.

0 comments:

Post a Comment