How to disable scientific notation in php

藏色散人
Release: 2023-03-12 19:10:01
Original
2540 people have browsed it

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
Copy after login

There is also an online chestnut:

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

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!

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