PHP Data Type Detection Example detailed

Source: Internet
Author: User
PHP: Array data type instance details in PHP, there are a series of functions that detect data types, which can be used to detect different types of data to determine if they belong to the meter data type, and return true if they match, otherwise false.

The functions of the PHP detection data type are the following table

Function Detection type Example
Is_bool Detects if a variable is a Boolean type Is_bool (True), Is_bool (false)
Is_string Detects if a variable is a string type Is_string (' string '), is_string (1234)
Is_integer/is_int Detects if a variable is an integer Is_integer (Is_integer), (' 34 ')
Is_float/is_double Detects if a variable is a floating-point type Is_float (3.1415), is_float (' 3.1415 ')
Is_array Detects if a variable is an array type Is_array ($arr)
Is_object Detects if a variable is an object type Is_object ($obj)
Is_null Detects if a variable is null Is_null (NULL)
Is_numeric A string that detects whether a variable is a number or a number Is_numeric (' 5 '), Is_numeric (' bccd110 ')
PHP Data Type detection instance

The functions and usages of the PHP detection data type are the same, and the following example uses the Is_numeric () function to detect whether the data in the variable is a number.

<?phpheader ("Content-type:text/html;charset=utf-8");              Set character encoding $boo= "1234567890";             Describes a string variable that consists entirely of numbers if (Is_numeric ($boo)) {                                   //Determines whether the variable is made up of numbers    echo "Variable Boo belongs to a string type consisting of numbers:". $boo;       If the variable is output}else    echo "cannot be judged";//Otherwise, the statement is output?>

Code Run Result:

The above example is the use of our is series functions.

In this chapter, we explain a series of PHP data types: PHP Eight data types, PHP: Boolean type (Boolean) data type instance, PHP: String data type instance details, PHP: integer type (integer) data type instance detailed, PHP: Examples of floating-point (float) data types in detail, PHP: Array data type instances, PHP: Object data type examples, PHP: Resource (Resource) data type examples, PHP: null (NULL) data type instance in detail, PHP data type Conversion example in detail I hope you through this series of learning, PHP data types have a deeper understanding.

Related video tutorial recommended: "Php.cn lonely Nine Cheap (4)-php video tutorial": PHP Data type

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.