PHP Data Types
In this chapter you will learn:
Data types in PHP
PHP has seven data types. The seven types are:
string,
integer,
float,
boolean,
array,
object, and
resource.
String
Strings hold characters such as "a," "abc," "www.java2s.com," etc. PHP strings are case-sensitive.
Integer
Integers hold whole numbers, either positive or negative, such as 1, -20, 12345,etc. The limit of integer is between -2147483647 and 2147483647. The integer numbers outside the range are automatically converted to floats.
Float
Floats hold fractional numbers as well as very large integer numbers, such as 4.2, 1.00000001, and 123123123123000.
Boolean
Booleans hold either true or false. Behind the scenes, booleans are integers.
Array
Arrays are a special variable type in that they hold multiple values like a container.
Object
Objects are complex variables that have multiple values, and they can have their own functions.
Resource
Resources might be picture data, or the result of an SQL query. We should free up resources after using them.
Next chapter...
What you will learn in the next chapter:
- What is boolean value in PHP
- What values are considered false
- Example - Use PHP boolean value
- Example - Convert integer to boolean