In PHP, a variable's data type is not determined by the developer. At the time of interpretation of the web page, PHP decides the data type of variables.
Numeric Data Type
There are two different numeric data types, which are used for number:
- Double (floating point numbers)
Integer Data Type
Integer data type has full number values.
<?php $intValue = 100; ?>
Double Data Type
Floating point numbers are the contains Double.
<?php $doubValue = 55.5; ?>
String Data Type
String data type contains letters or textual information. Value is assigned to the double or single quotes.
<?php $strName = "Neel"; $strId = "Neel456"; ?>
Converting Between Data Types
<?php $a = 9.88; echo (int) $a; // Outputs 9 ?>
Values cannot be converted to certain types; for example, you cannot convert any value into a resource. However, you can convert a resource into a numerical or string data type, in which case PHP will return the numeric ID of the resource, or the string Resource id # followed by the resource ID.