In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how php displays only 3 decimal places, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
In PHP, you can use the number_format () function to display 3 decimal places, which can format numbers by grouping numbers in thousands of places, and can set the number of decimal places that return the result, with the syntax "number_format (numeric object to be formatted, 3);".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of displaying only 3 decimal places in php
1. Create a new php file, named test.php, to explain how php sets the number of decimal places. Use the header () method to set the encoding format of the page to utf-8. Create a decimal variable for testing.
2. In the test.php file, use the number_format function to keep the number to 3 decimal places, and the result is saved in the $res variable. Output the result of decimal processing through echo.
Open the test.php file in a browser and view the results.
Summary:
1. Create a decimal variable for testing.
2. Use the number_format function to keep the number to 3 decimal places, and the result is saved in the $res variable.
3. Output the result of decimal processing through echo.
The above is all the contents of the article "how to display only 3 decimal places in php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.