Getting the variable type
Get variable type: gettype()
If you have a variable and you need to detect the type (βstringβ, βintegerβ, βbooleanβ, β¦) you can use the gettype()
function.
It returns a string with the name of the type.
// gettype of 1 is an integerecho gettype(1) . PHP_EOL; // "integer"//gettype of "1" is a stringecho gettype("1") . PHP_EOL; // "string"
It works also with array, object and resources (file opened or closed).