Home > Backend Development > PHP Tutorial > 数字类型问题

数字类型问题

WBOY
Release: 2016-06-23 13:36:37
Original
1247 people have browsed it

$n_qz="1".$number.date("mdhis");
$head=str_pad($n_qz,15,0);
while($rs=$sql->fetch_array($query)){
echo strval($head)."
";
$head++;
}

110413110344000
1.10413110344E+14
1.10413110344E+14
1.10413110344E+14
1.10413110344E+14
1.1041311034400E+14

除了第一个输出正常,其它的怎么全变成这样了??请问怎么解决,我要数字。


回复讨论(解决方案)

科学计数法,很正常
如果不是你期望的,那请将长数字串当字符串处理

你的数字来自数据库,可能数据库里已经是科学计数法的格式了

试试这样

$str = 1.10413110344E+14;echo sprintf("%.0f", $str);
Copy after login

我这个不是读数据库的,是直接生成的,有些服务器不会变成科学计数法,谢谢各位大神啦!
我的解决办法是:
number_format($head,0,"","")

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template