Home  >  Article  >  Backend Development  >  How to disable scientific notation in php

How to disable scientific notation in php

藏色散人
藏色散人Original
2021-09-20 09:57:122527browse

In PHP, you can use the formatting number function "number_format()" to prevent numbers from being displayed in scientific notation. Use methods such as "echo number_format("5000000",2,",",".") ;".

How to disable scientific notation in php

The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

How to disable scientific notation in php? PHP prevents numbers from being displayed as scientific notation

When encountering scientific notation

The solution is

Use PHP formatting number function: number_format()

The usage method is as follows:

echo number_format("5000000")."<br>";
//5,000,000
echo number_format("5000000",2)."<br>";
//5,000,000.00
echo number_format("5000000",2,",",".");
//5.000.000,00

There is also an online chestnut:

//举个例子
echo &#39;1869879738796128&#39;;
//默认结果为:1.8698797387961E+15
 
//解决办法
echo number_format(‘1869879738796128’, 0, &#39;&#39;, &#39;&#39;);
//输出结果为:1869879738796128

Recommended learning: "PHP Video Tutorial

The above is the detailed content of How to disable scientific notation in php. For more information, please follow other related articles on the PHP Chinese website!

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