php: Detailed explanation of array data type examples In PHP, there are a series of functions for detecting data types. Different types of data can be detected to determine whether they belong to the MiG data type. If they match, true will be returned. Otherwise return false.
PHP functions to detect data types are as follows
##Function | Detection type | Example |
is_bool | Detect whether the variable is of Boolean type | is_bool(true),is_bool(false) |
is_string | Detect whether the variable is of string type | is_string('string'),is_string(1234) |
is_integer/is_int | Detect whether the variable is an integer | is_integer(34),is_integer('34') |
##is_float/is_double
Detect whether the variable is of floating point type |
is_float(3.1415),is_float('3.1415') |
|
is_array
Detect whether the variable is For array type |
is_array($arr) |
| ##is_object
Detect whether the variable is an object type | is_object($obj ) |
| is_null
Detect whether the variable is null | is_null(null) |
| is_numeric
Detect whether the variable is a number or a string of numbers | is_numeric('5'),is_numeric('bccd110') |
|
PHP data type detection example
The functions and usage of PHP data type detection functions are the same. Our following example uses the is_numeric() function to detect whether the data in the variable is It's a number.
<?php
header("content-type:text/html;charset=utf-8"); //设置字符编码
$boo="1234567890"; //说明一个全由数字组成的字符串变量
if(is_numeric($boo)){ //判断该变量是否由数字组成
echo "变量boo属由数字组成的字符串类型:".$boo; //如果是输出该变量
}else
echo"无法判断"; //否则,输出该语句
?>
Copy after login
Code running results:
The above example is the usage of our is series functions.
In this chapter, we have explained a series of PHP data types: Eight data types of PHP, php: Detailed explanation of Boolean data type examples, php: Detailed explanation of string data type examples , php: Detailed explanation of integer data type examples , php: Float data type examples Detailed explanation , php: Detailed explanation of array data type instance , php: Detailed explanation of object data type instance , php: Resource data type Detailed explanation of examples , php: Detailed explanation of null data type examples , Detailed explanations of php data type conversion examples I hope that through this series of studies, you will have an understanding of PHP data types. A deeper understanding.
Recommended related video tutorials: "php.cn Dugu Jiujian (4)-php video tutorial" : PHP data type
The above is the detailed content of Detailed explanation of PHP data type detection examples. For more information, please follow other related articles on the PHP Chinese website!