In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces php how to judge a number is a number of digits, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Php to determine how many digits a number is: 1, use the floor () function to process the specified number and convert it into an integer; 2, use the strlen () function to count the number of characters contained in the integer, you can calculate the number of digits of the specified number, syntax "strlen (floor ($num))".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
How does php determine how many digits a number is?
In php, there are two ways to determine how many digits a number is:
If the number is an integer, you can directly use the strlen () function to get the number of characters and determine the number of digits.
The strlen () function returns the length of the string. Returns the length of the string if successful, and 0 if the string is empty.
Numbers are floating-point numbers (including decimals), so you need to round them first (using the floor () function) and get the number of characters using the strlen () function.
The floor () function rounds down to the nearest integer.
Let's take a look at the implementation code:
Thank you for reading this article carefully. I hope the article "php how to judge a number is a number" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.