Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Php plastic conversion to floating point, accurate to two decimal places.
Php plastic conversion to floating point, accurate to two decimal places.
Sprintf function in PHP can format integers into floating-point format. For example, format parameter:% nf where n represents the number of digits after the decimal point. For example:

& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)

$ num = 9.8

$res=sprintf("%.2f ",$ num);

//Output: 9.80

& gt