Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the gettype() say it's a double but var_dump() says float?

Why does the gettype() say it's a double but var_dump() says float?

$number = 1234567890123456789;
echo "Number: {$number} is a ". gettype($number) . "\n";
var_dump($number);

Response:

Number: 1.23456789012E+18 is a double
float(1.23456789012E+18)

like image 663
Phill Pafford Avatar asked Nov 04 '11 15:11

Phill Pafford


2 Answers

They're the same thing http://php.net/manual/en/language.types.float.php

like image 64
Matteo Pagliazzi Avatar answered Sep 16 '22 14:09

Matteo Pagliazzi


Directly from PHP.net (gettype()):

Possibles values for the returned string are:

... "double" (for historical reasons "double" is returned in case of a float, and not simply "float") ...

like image 44
Bee Avatar answered Sep 17 '22 14:09

Bee