Home  >  Article  >  Backend Development  >  PHP number, character, object judgment function_PHP tutorial

PHP number, character, object judgment function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:02:56877browse

Judging numbers, characters, objects, arrays, etc. in PHP 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 you know. Woolen cloth. ​

//Double precision number judgment

is_double
is_double -- alias of is_float()
Description
This function is an alias for is_float().

The code is as follows Copy code
 代码如下 复制代码

$Temperature = 15.23;
if(is_double($Temperature))
{
print("Temperature is a double"."
");
}

$Temperature = 15.23;

if(is_double($Temperature)) { print("Temperature is a double"."

");

}


//Integer judgment

 代码如下 复制代码
$PageCount = 2234;
if(is_integer($PageCount))
{
print("$PageCount is an integer"."
");
}
is_integer -- alias for is_int() and is_long()

Description
This function is an alias for is_int().

The code is as follows Copy code
$PageCount = 2234;

if(is_integer($PageCount))
{
print("$PageCount is an integer"."

");

}


//Object judgment

 代码如下 复制代码

class widget
{
var $name;
var $length;
}
$thing = new widget;
if(is_object($thing))
{
print("thing is an object"."
");
}

is_object -- Check whether the variable is an object
Description bool is_object (mixed var)

Returns TRUE if var is an object, FALSE otherwise.

The code is as follows Copy code

class widget
{

var $name;

var $length;

}
 代码如下 复制代码
$Greeting = "www.hzhuti.com ";
if(is_string($Greeting))
{
print("Greeting is a string"."
");
}
$thing = new widget;

if(is_object($thing))
{ print("thing is an object"." ");
}


//Character judgment

 代码如下 复制代码

$int = 1;
if(is_numeric($int))
{
print("这是个真正的数字,纯爷们"."
");
}

is_string -- Check whether the variable is a string Description bool is_string (mixed var) Returns TRUE if var is a string, FALSE otherwise.
The code is as follows Copy code
$Greeting = "www.hzhuti. com "; if(is_string($Greeting)) { print("Greeting is a string"." "); }
is_numeric -- Check whether the variable is a number or a numeric string Description bool is_numeric (mixed var) Returns TRUE if var is a number or numeric string, FALSE otherwise.
The code is as follows Copy code
$int = 1; if(is_numeric($int)) { print("This is a real number, just a man"." "); }


Okay, this article just briefly talks about the object, number, and character judgment functions in PHP. The difficulty is relatively simple.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445312.htmlTechArticleJudge numbers, characters, objects, arrays, etc. in PHP, including see is_bool(), is_int(), is_integer( ), is_float(), is_real(), is_object() and is_array(). I don’t know about you...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn