Home  >  Article  >  Backend Development  >  数字类型问题

数字类型问题

WBOY
WBOYOriginal
2016-06-23 13:36:371145browse

$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);

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

Statement:
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