PHP has several types of variables. The PHP variable types are:
· String – Strings are a sequence of characters that are always internally NULL terminated. String variable hold characters. Usually a set of characters such as “C”, “Cyber Teak”, “PHP is very popular language” and so on. Strings can be as short or as long as desired. There is no limit to size.
· Integer – Integer variables hold whole numbers, either positive or negative such as 4, -20, 34534534 and so on. There is a maximum limit of size of integers. Any numbers lower than -2147483647 and higher then 214748647 are automatically converted to floats as this data type can hold a much larger range of values.
· Float – Float variables hold fractional numbers as well as very high integer numbers such as 2.5, 1.00000001, 2147483647000 and so on.
· Boolean – Boolean variables hold TRUE OR FALSE. Behind the scenes these are just integers. PHP considers the number 0 to be FALSE and everything else to be TRUE.
· Array - Arrays are a special variable type, which hold multiple values. They are a great way of storing variable that are related such as colors, days of the week, members of a team or items in a shopping basket.
· Object – Object variables are complex variables that have their own functions for accessing and/or manipulating their content.
· Resource – Resource variables are variables that hold anything that is not PHP data. This could be picture data loaded from a file, the result of an SQL query and so on. A Resource type variable is used like any other variable with the ley difference being that they should be freed up by the user when not required.
0 Comments