Php variable data type judgment function instance code

Source: Internet
Author: User
The following small series will bring you an article on the data type judgment function of variables in php. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at the following small series to bring you an article on the data type judgment function of variables in php. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at it with Xiaobian.

In php, we can print the type and value of the variable through var_dump. At the same time, we can use some functions to determine the type of the variable. If you only want to get the data type of a variable, you can use the gettype () function. gettype ($ t) returns a $ t data type string, if $ t does not belong to eight basic variable types in php, "unknow type" is returned ". We can also use the is_type class function to directly determine whether it is a type function. If yes, true is returned, rather than false.

For example:


Is is_bool () Boolean?
Whether is_int () is an integer
Whether is_float () is float
Whether is_string () is string type
Whether is_array () is array type
Whether is_object () is of the object type
Whether is_resource () is a resource type
Is_null () is empty?
Whether is_scalar () is a scalar type is an integer floating-point Boolean type or a string type.
Whether is_numeric () is a numeric or numeric string of any type
Whether is_callable () is a valid function name

The above is the content of the code of the function instance for determining the data type of variables in php. For more information, see The PHP Chinese website (www.php1.cn )!

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.