Recommended Manual: php complete self-study manual
##php Commonly used functions for judging variables include gettype(), is_array(), is_bool(), is_float(), is_integer(), is_null(), is_numeric(), is_object(), is_resource(), is_scalar() and is_string() .
The gettype() function returns the type of the variable, such as "boolean", "integer", "double" (the float type will return "double" instead of "float"), "string", "array" ", "object", "resource", "NULL" and "unknown type" and other values indicate the variable type, such as:1 2 |
|
1 2 3 4 |
|
1.settype($var,type) function conversion
1 2 3 |
|
2. Target type specified conversion
1 |
|
3. Three specific type function conversion
intval($var) , floatval($var) and strval($var)1 2 |
|
Recommended related articles: 1.
How does PHP use the gettype() function to determine the type of a variable? 2.
How does php determine the file type 3.
php implementation to determine client type
Related video recommendations: 1.
Dugu Jiujian (4)_PHP video tutorial
The above is the detailed content of PHP determines variable type. For more information, please follow other related articles on the PHP Chinese website!