Double datatype in PHP
How to define a double variable and assign value?
The Double data type is used to specify floating point numbers.
When you are declaring double variable, you can declare as given below
where double denotes the type of the variable.
The range of floating point numbers in PHP is equivalent to the range of the double type in C, Double can range from 1.7E-308 to 1.7E+308. A double may be expressed either as a regular number with a decimal point or in scientific notation.
You can also declare variable without datatype, in such case PHP will try to determine type of variable based on the value hold by that variable. Below I have declared a variable without its type.
Here the variable hold the floating point value so it is of type double.
If you want to get a type of a variable, you can use gettype() function.
Above code will print type double because floating point value is assigned to that variable. If you want to permanently change type of variable then you can use typecast function
such as settype() to change the type of the variable. If you want to change type temporary, eg just for use in an expression then you will use type casting.