Follow us on Facebook
Faucibus toroot menuts
PHP Data Types
Before we proceed for knowing about out data types, let’sbear in mind that PHP is a loosely typed language. Java, C, C++ etc. are strongly typed language. The later programing langue are called strongly typed language because we must define data type before using it. And we can store value in variable only as defined data type. PHP is called loosely typed language because we don’t specifically define data type for PHP variables. So, if we define a variable say $a; we can store either number or string both. PHP automatically converts it to required data type.
From the above example, you can understand that same variable a can store integer value as well as string also. So, whether you call it strength or weakness, PHP is like that and it’s a magical power for PHP also In spite of that PHP supports data various data types where we can specifically define data type.
PHP supports following data types:
String is a list of characters. Like "I am Indian";
If you want to see data type, you can apply var_dump();
Floating point numbers are those which has decimal numbers "floats", "doubles” comes under this.
And the output :
This is the easiest type. A Boolean expresses a truth value. It can be either TRUE or FALSE.
Array is a group of objects which has common name and its elements is identified by its index.
An object is a collection of data and code. To initialize an object, you use the new statement to instantiate the object to a variable.
Null data types denotes that the variable contains NULL value. NULL is the only possible value of type NULL. A variable is considered to be NULL if it has been assigned the constant NULL. it has not been set to any value yet. it has been unset().
That is the case insensitive keyword NULL.
Resource Data Types A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions