php method to set up not using scientific notation: first use the number_format() function to format the number by thousands grouping, the syntax is "number_format(number)"; then output the formatted number through the echo statement .
Recommended: "PHP Video Tutorial"
When you meet scientific notation
The solution is to
Use the PHP formatting number function:number_format()
number_format() function formats numbers by grouping thousands.
Note: This function supports one, two or four parameters (not three).
Syntax:
number_format(number,decimals,decimalpoint,separator)
number Required. The number to format. If no other parameters are set, the number is formatted without a decimal point and with a comma (,) as the thousands separator.
decimals Optional. Specify the number of decimals. If this parameter is set, numbers are formatted using a period (.) as the decimal point.
decimalpoint Optional. Specifies the string used as the decimal point.
separator Optional. Specifies the string used as thousands separator. Only the first character of the parameter is used. For example, "xxx" only outputs "x".
Note: If this parameter is set, all other parameters are required.
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 a chestnut online:
//举个例子 echo '1869879738796128'; //默认结果为:1.8698797387961E+15 //解决办法 echo number_format(‘1869879738796128’, 0, '', ''); //输出结果为:1869879738796128
related Recommended: php training
The above is the detailed content of How to set PHP not to use scientific notation?. For more information, please follow other related articles on the PHP Chinese website!