The method for checking the variable type in php is very simple. you can use the gettype () function to return the current variable type. next I will introduce you to the gettype function to check the variable type in detail, for more information, see. stringg... the method for checking the variable type in php is very simple. you can use the gettype () function to return the current variable type. next I will introduce you to the gettype function to check the variable type in detail, for more information, see.
String gettype (mixed $ var) returns the PHP variable type var.
The instance code is as follows:
The official saying: do not use gettype () to test a type, because the returned string may need to be changed in future versions. in addition, because it contains a string comparison, it runs slowly.
Use the is _ * function instead of the. instance code as follows:
Other variable types
Array_key_exists (mixed key, array search): // check whether the given key name or index exists in the array to determine the data type is_numeric (mixed var ): // check whether the measurement variable is a digital or digital string is_bool ($ var): // check whether the measurement variable is a Boolean is_float ($ var ): // check whether the measurement variable is floating point or is_double or is_real (). is_int ($ var): // check whether the measurement variable is an integer () in the same usage, is_string ($ var): // checks whether the variable is a string is_object ($ var): // checks whether the variable is an object is_array ($ var ): // check whether the measurement variable is an array is_null ($ var): // check whether the measurement variable is null.
Tutorial link:
Reprint at will ~ However, please keep the tutorial address★