Home > php教程 > php手册 > body text

JS和php保留两位小数例子 四舍五入使用函数toFixed()

WBOY
Release: 2016-06-13 10:42:18
Original
1553 people have browsed it

JS保留两位小数例子 四舍五入使用函数toFixed()








 

php保留两位小数例子 四舍五入

1.number_format
$number = 1234.5678;
$nombre_format_francais = number_format($number, 2, ,, );
// 1 234,57
$english_format_number = number_format($number, 2, ., );
// 1234.57

2.round
$number = 1234.5678;
echo round($number ,2);
//1234.57

3.sprintf
$formatted = sprintf ("%s有¥%01.2f。",$name, $money);
echo $formatted;   
//张三有¥123.10。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template