PHP number, character, object judgment function _php Tutorial

Source: Internet
Author: User
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.

Double Precision number judgment

Is_double
Is_double--alias of Is_float ()
Describe
This function is an alias function of Is_float ().

The code is as follows Copy Code

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

Integer judgments

Aliases for Is_integer--is_int () and Is_long ()
Describe
This function is an alias function of Is_int ().

The code is as follows Copy Code
$PageCount = 2234;
if (Is_integer ($PageCount))
{
Print ("$PageCount is an integer". "
");
}


Object judgment

Is_object--detects if a variable is an object
Describe
BOOL Is_object (mixed Var)


Returns TRUE if Var is an object, otherwise FALSE.

The code is as follows Copy Code

Class Widget
{
var $name;
var $length;
}
$thing = new Widget;
if (Is_object ($thing))
{
Print ("thing is an object". "
");
}


Character judgment

Is_string--detects if a variable is a string
Describe
BOOL Is_string (mixed Var)


Returns TRUE if Var is a string, otherwise FALSE.

The code is as follows Copy Code
$Greeting = "www.hzhuti.com";
if (is_string ($Greeting))
{
Print ("Greeting is a string". "
");
}


Is_numeric--detects if a variable is a numeric or numeric string
Describe
BOOL Is_numeric (mixed Var)


Returns TRUE if Var is a numeric and numeric string, otherwise FALSE is returned.

The code is as follows Copy Code

$int = 1;
if (Is_numeric ($int))
{
Print ("This is a real figure, pure man.")
");
}


Okay, this article is simply about the PHP object, the number, the character judgment function, the difficulty is relatively super simple.


http://www.bkjia.com/PHPjc/445312.html www.bkjia.com true http://www.bkjia.com/PHPjc/445312.html techarticle 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 (), Don't know you ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.