Methods and techniques for detecting data types in PHP

Source: Internet
Author: User
The following is a summary of several methods for detecting data types 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 a PHP several methods for detecting data types (summary ). 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 JavaScript, typeof can be used to detect basic data types, and instanceof can be used to detect referenced data types. In PHP, there are also methods for detecting data types, as shown below:

1. gettype)

 

2. data type, quantity, and content of the output variable (var_dump)

View source code printing Code Help

 
 

3. check whether a variable is of the specified data type (is_array, is_string, is_int, is_double, etc.). if it is true, return 1. if it is false, return null.

View source code printing Code Help

 
 

Maybe your friend is looking for the answer to this question. please share it with him!

The above is a summary of several methods and tips for PHP to detect data types. For more information, see 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.