Home  >  Article  >  Backend Development  >  php get and set variable type

php get and set variable type

WBOY
WBOYOriginal
2016-07-25 08:45:541058browse

gettype-Get variable type
Grammar:
string gettype (mixed $var)
Possible values ​​for the returned string are:
boolean
integer
double
string
array
object
resource
null
unknown type
Note:
Don't use gettype() to test a certain type, because the string it returns may change in future PHP versions, and it also runs slower because it involves string comparisons. It is recommended to use the is_ function instead.
If testing functions, function_exists() and method_exists() should be used.
is_
series functions:
is_array(): Checks whether the variable is an array.
is_double(), is_float(), is_real(): Check whether the variable is a floating point number.
is_long(), is_int(), is_integer(): Check whether the variable is an integer.
is_string(): Check whether the variable is a string.
is_bool(): Checks whether the variable is a Boolean value.
is_object(): Checks whether the variable is an object.
is_resource(): Checks whether the variable is a resource.
is_null(): Check whether the variable is null.
is_scalar(): Checks whether the variable is a scalar, i.e., an integer, boolean, string, or floating point number.
is_numeric(): Check if the variable is any type of number or numeric string.
is_callable(): Checks whether the variable is a valid function name.

settype-Set the type of variable
Grammar:
bool settype (mixed &$var,string $type)
Description:

Set the type of variable var to type.

php


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn