5

gettype()がdoubleと言うのに、var_dump()がfloatと言うのはなぜですか?

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

応答:

番号:1.23456789012E + 18はダブル
フロート(1.23456789012E + 18)

4

3 に答える 3

9

それらは同じものですhttp://php.net/manual/en/language.types.float.php

于 2011-11-04T15:45:02.617 に答える
6

PHP.netから直接(gettype()):

返される文字列に可能な値は次のとおりです。

... "double"(歴史的な理由から、単に "float"ではなく、floatの場合は "double"が返されます) ..。

于 2011-11-04T15:46:34.033 に答える
0
<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));

?>
于 2016-06-02T15:28:19.460 に答える