In this paper, we describe the usage of numeric, character and object judgment functions in PHP. Share to everyone for your reference. The specific analysis is as follows:
In PHP judging numbers, characters, objects, arrays, etc. include the functions of See Is_bool (), Is_int (), Is_integer (), Is_float (), Is_real (), Is_object (), and Is_array (), I don't know how much you know.
1. Double-precision number judgment: is_double
Is_double--alias of Is_float ()
Description: This function is an alias function for Is_float () and the code is as follows:
The code is as follows:
$Temperature = 15.23;
if (is_double ($Temperature))
{
Print ("Temperature is a double". "
");
}
2. Integer judgment: Aliases for Is_integer--is_int () and Is_long ()
Description: This function is an alias function for Is_int () and the code is as follows:
The code is as follows:
$PageCount = 2234;
if (Is_integer ($PageCount))
{
Print ("$PageCount is an integer". "
");
}
3. Object judgment: Is_object--Detects if a variable is an object
Description: BOOL Is_object (mixed Var)
Returns TRUE if Var is an object, otherwise returns FALSE, the code is as follows:
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 if a variable is a string
Description: BOOL Is_string (mixed Var)
Returns TRUE if Var is a string, otherwise returns FALSE, the code is as follows:
The code is as follows:
$Greeting = "www.bitsCN.com";
if (is_string ($Greeting))
{
Print ("Greeting is a string". "
");
}
5. Is_numeric--Whether the detection variable is a numeric or numeric string
Description: BOOL Is_numeric (mixed Var)
Returns TRUE if Var is a numeric and numeric string, otherwise FALSE, the code is as follows:
The code is as follows:
$int = 1;
if (Is_numeric ($int))
{
Print ("This is a real figure, pure man.")
");
}
Here is simply the story of the PHP object, number, character judgment function, the difficulty is relatively super simple. I hope this article is helpful for PHP program design.