Current File : //usr/share/tests/pecl/json/tests/json_decode_float.phpt |
--TEST--
Test json_decode() function with float
--SKIPIF--
<?php
if (!extension_loaded("json")) {
die('skip JSON extension not available in this build');
}
?>
--FILE--
<?php
$good = "[
3.367369e+26,
336736864456782105775439872.000000,
1.461826e-08,
0.000000,
1.391588e+22,
13915880780094861475840.000000,
2.116600e+23,
211660013157571985670144.000000,
1.120987e+32,
112098729821300864932370706333696.000000,
1.041024e-23,
0.000000,
4.131437e-13,
0.000000,
9.838910e+20,
983890996017493966848.000000,
1.540887e-17,
0.000000,
2.975840e+04,
29758.400391,
3.792641e-02,
0.037926,
1.710219e+10,
17102187520.000000,
8.060742e-11,
0.000000,
2.289013e+01,
22.890127,
1.471131e+35,
147113100255597364294271623793475584.000000,
2.508427e+32,
250842668277236002726935414177792.000000,
5.986161e+10,
59861614592.000000,
1.173108e+17,
117310761037987840.000000,
5.049736e-28,
0.000000,
3.715233e+08,
371523328.000000,
0
]";
$d = json_decode($good);
var_dump(is_array($d), count($d));
$bad = array(
"12.34.56.78",
"12.34e12.34",
"12e34e56",
"12e34.56",
);
foreach($bad as $t) {
var_dump(json_decode($t));
}
?>
Done
--EXPECT--
bool(true)
int(41)
NULL
NULL
NULL
NULL
Done