On the data type Judgment function instance code of variables in PHP

Source: Internet
Author: User
The following small series for everyone to bring a brief talk about the variables in PHP data type judgment function. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.

In PHP we can print out the type and value of the variable by Var_dump (). At the same time, we can determine the type of variables through some functions. If you just want the data type of a variable, you can use the GetType () function, GetType ($t) to return the string of the $t data type, and if $t is not part of 8 basic variable types in PHP, return "Unknow type". We can also directly determine whether the type is a function by using the Is_type class function, which returns TRUE, not return false.

Such as:


Is_bool () is Boolean
Is_int () is an integral type
Is_float () is a floating-point type
Is_string () is a string type
Is_array () is an array type
Is_object () is an object type
Is_resource () is a resource type
Is_null () is empty
Is_scalar () is a scalar type, which is an integer floating-point Boolean or String type.
Is_numeric () is any type of numeric or numeric string
Is_callable () is a valid function name

The above is about the variables in PHP data type Judgment function instance code content, more relevant content please pay attention to topic.alibabacloud.com (www.php.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.