Usage examples of number, character and object judgment functions in php, php examples
The examples in this article describe the usage of number, character and object judgment functions in PHP. Share it with everyone for your reference. The specific analysis is as follows:
In PHP, judging numbers, characters, objects, arrays, etc. includes functions such as is_bool(), is_int(), is_integer(), is_float(), is_real(), is_object() and is_array(). I don’t know. How much do you know.
1. Double precision number judgment: is_double
is_double -- alias of is_float()
Description: This function is an alias function of is_float(), the code is as follows:
Copy code The code is as follows:
$Temperature = 15.23;
if(is_double($Temperature))
{
print("Temperature is a double"."
");
}
2. Integer judgment: is_integer -- alias of is_int() and is_long()
Description: This function is an alias function of is_int(), the code is as follows:
Copy code The code is as follows:
$PageCount = 2234;
if(is_integer($PageCount))
{
print("$PageCount is an integer"."
");
}
3. Object judgment: is_object -- detect whether the variable is an object
Description: bool is_object(mixed var)
If var is an object, return TRUE, otherwise return FALSE, the code is as follows:
Copy code The code is as follows:
class widget
{
var $name;
var $length;
}
$thing = new widget;
if(is_object($thing))
{
print("thing is an object"."
");
}
4. Character judgment: is_string -- detect whether the variable is a string
Description: bool is_string(mixed var)
If var is a string, return TRUE, otherwise return FALSE, the code is as follows:
Copy code The code is as follows:
$Greeting = "www.jb51.net";
if(is_string($Greeting))
{
print("Greeting is a string"."
");
}
5. is_numeric -- Detect whether the variable is a number or a numeric string
Description: bool is_numeric(mixed var)
If var is a number or numeric string, it returns TRUE, otherwise it returns FALSE. The code is as follows:
Copy code The code is as follows:
$int = 1;
if(is_numeric($int))
{
print("This is a real number, just a man"."
");
}
Here is just a brief introduction to the object, number, and character judgment functions in PHP. The difficulty is relatively simple. I hope this article will be helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/917684.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/917684.htmlTechArticleUsage examples of numbers, characters and object judgment functions in php, php examples This article tells the examples of numbers, characters and objects in php Object judgment function usage. Share it with everyone for your reference. Detailed analysis...