PHP Data type detection instance details

Source: Internet
Author: User
In PHP, there are a series of functions that detect data types. different types of data can be checked to determine whether the data belongs to the MiG data type. If yes, true is returned; otherwise, false is returned. Php: an array of data type instances. in PHP, there are a series of functions that can be used to detect different types of data to determine whether the data belongs to the MiG data type, if yes, true is returned. otherwise, false is returned.

The following table lists the functions used by PHP to detect data types:

Function Detection type Example
Is_bool Check whether the variable is Boolean Is_bool (true), is_bool (false)
Is_string Checks whether the variable is of the string type. Is_string ('string'), is_string (1234)
Is_integer/is_int Check whether the variable is an integer. Is_integer (34), is_integer ('34 ')
Is_float/is_double Checks whether the variable is of the floating point type. Is_float (3.1415), is_float ('3. 1415 ')
Is_array Checks whether the variable is of the array type. Is_array ($ arr)
Is_object Checks whether the variable is an object type. Is_object ($ obj)
Is_null Checks whether the variable is null. Is_null (null)
Is_numeric Checks whether the variable is a string consisting of digits or numbers. Is_numeric ('5'), is_numeric ('bccd110 ')
PHP Data type detection instance

PHP checks whether the functions and usage of the data type are the same. the following example uses the is_numeric () function to check whether the data in the variable is a number.

 

Code running result:

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

In this chapter, we will explain a series of PHP Data types: eight data types of PHP, php: boolean data type instances, php: string) details about data type instances, php: integer data type instances, php: float data type instances, php: array data type instances, php: details about object data type instances, php: resource data type instances, php: null data type instances, I hope you will learn more about php Data types through this series.

Related video tutorials are recommended: php1.cn solitary 9 cheap (4)-php Video Tutorial: PHP data type

The above is a detailed description of the PHP Data type detection instance. For more information, see other related articles in the first PHP community!

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.