Home > Article > Backend Development > Common methods for determining variable types in PHP_PHP tutorial
Now let us understand the specific usage
gettype()
gettype will return the following values according to the parameter type
"boolean" (from PHP 4)
"integer"
"double" (returns "double" instead of "float" if float)
"string"
"array"
"object"
"resource" (since PHP 4)
"NULL" (from PHP 4)
"unknown type"
For example:
gettype('1'); returns string
while gettype(1); returns is integer
is_array()
The usage of is_array() is relatively simple
If the parameter is an array, it returns true, otherwise it returns false
The usage of several other functions and The return value is similar to is_array()
It should be noted here that is_numeric() is used to determine whether the variable is a number or a string of numbers
When the parameter of is_numeric() is a number or a string of numbers, it returns true Otherwise return false