The method of accurate number of decimal places in php
This article is about the precise number of decimal places in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Php decimal precision method: 1, use sprintf () function to format, syntax "sprintf ("%. Using the number_format () function, the syntax "number_format ($num,' decimal places')".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of accurate post-decimal place of php decimal point
Method 1: use sprintf to format strings
Method 2: using the number_format () function
Number_format (): the function can format numbers in the form of thousand-bit groupings.
Syntax:
Number_format (number,decimals,decimalpoint,separator)
Parameters:
Number: required. The number to format.
Decimals: optional. How many decimals are required
Decimalpoint: optional. Specifies a string to use as a decimal point.
Separator: optional. Specifies the string to use as a thousand-bit delimiter.
Example:
Thank you for reading! This is the end of this article on "the method of accurate decimal places in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!