In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how php determines whether a variable is a number or not. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Php to determine whether the variable is a number: 1, use the "gettype ($var)" statement, if the return value is "integer" or "double", it is a number; 2, use the "is_numeric ($var)" statement, if the return value is "TRUE", it is a number and a numeric string.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php determines whether a variable is a number or not
Method 1: use the gettype () function
Output result:
It's numbers.
Note: the gettype () function is used to obtain the type of variable, and the return value can be:
Boolean
Integer
Double (from PHP 4, return "double" instead of "float" if it is float)
String
Array
Object
Resource (Resource)
Resource is a special type of variable that holds a reference to an external resource; it mainly describes an extended resource of PHP. Resource (resources) are created and used through special functions.
NULL
NULL is also a special data type, which has only one value, NULL, which represents a null value (that is, a variable has no value).
Unknown type
Method 2: use the is_numeric () function
Checks whether the variable $var is a number or a numeric string, and returns TRUE if $var is, otherwise the FALSE; syntax "is_numeric ($var)" is returned.
Output result:
It's numbers.
About php how to judge whether the variable is a number or not, I hope the above content can be of some help to everyone and can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.