Php numeric, character, object judgment function

Source: Internet
Author: User
Tags numeric mixed

// Double-precision data determination

Is_double
Is_double -- is_float () alias
Description
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". "<br> ");
}

// Integer judgment

Is_integer -- is_int () and is_long () aliases
Description
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". "<br> ");
}


// Object judgment

Is_object -- check whether the variable is an object
Description
Bool is_object (mixed var)


If var is an object, TRUE is returned; otherwise, FALSE is returned.

 

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". "<br> ");
}


// Character judgment

Is_string -- check whether the variable is a string
Description
Bool is_string (mixed var)


If var is a string, TRUE is returned; otherwise, FALSE is returned.

 

The code is as follows: Copy code
$ Greeting = "www.111cn.net ";
If (is_string ($ Greeting ))
{
Print ("Greeting is a string". "<br> ");
}


Is_numeric -- checks whether the variable is a numeric or numeric string
Description
Bool is_numeric (mixed var)


Returns TRUE if var is a number or number string; otherwise, returns FALSE.

The code is as follows: Copy code

$ Int = 1;
If (is_numeric ($ int ))
{
Print ("This is a real number, just man". "<br> ");
}


Well, this article briefly describes php Objects, numbers, character judgment functions, and the difficulty is relatively simple.

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.