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

3

6

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)

Giuliana answered 4/11, 2011 at 15:41 Comment(0)
L
10

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

Lowrey answered 4/11, 2011 at 15:45 Comment(1)
thats a problem in my caseNumeration
G
7

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") ...

Goolsby answered 4/11, 2011 at 15:46 Comment(0)
A
1
<br>
<?php 
        /*begins with a function that runs a Console msg for PHP */
function console_sn($txt){
$temp = "";
$temp .= "<script>";
$temp .= "console.info('frm_PHP: '+'";
$temp .= $txt;
$temp .= "');";
$temp .= "</script>";
echo $temp;
}
echo("<br><hr><br>");
//end of PHP console function

//Main primary code for this Example begins below

//run these examples below in your test PHP file and see the results in your JS console window

//e.g.#1
$code1 = "1212";
console_sn(gettype(floatval($code1)));

//e.g.#2
$code2 = "1212sn";
console_sn(gettype(floatval($code2)));

//e.g.#3
$code3 = "1212";
console_sn(gettype((trim($code3))*1));

//e.g.#4
$code4 = "1212sn";
console_sn(gettype((trim($code4))*1));

?>
Avera answered 2/6, 2016 at 15:28 Comment(1)
Copy and Paste this code block above into your PHP test file and see the results appear in your Javascript Console window.Avera

© 2022 - 2024 — McMap. All rights reserved.