php is a common method for determining variable types

  • 2020-05-16 06:32:15
  • OfStack

Now let's see how to use it

gettype()
gettype returns the following values based on the parameter type
"boolean" (from PHP 4 onwards)
"integer"
"double" (if it is float, return "double" instead of "float")
"string"
"array"
"object"
"resource" (from PHP 4 onwards)
"NULL" (from PHP 4 onwards)
"unknown type"

Such as:
gettype (' 1 '); The return is string
While gettype (1); The return is integer


is_array()
The use of is_array() is relatively simple
Returns true if the argument is an array otherwise returns false

The usage and return values of several other functions are similar to is_array()
The important thing to note here is that is_numeric() is used to determine whether a variable is a number or a number string
Returns true when the parameter is_numeric() is a numeric or numeric string otherwise returns false

Related articles: