The settype() function is used to set the type of a variable.
PHP version requirements: PHP 4, PHP 5, PHP 7
bool settype ( mixed &$var , string $type )
Parameter description:
$var: variable to be converted.
$type: Possible values for type are.
"boolean" (or "bool" since PHP 4.2.0)
"integer" (or "int" since PHP 4.2.0)
"float" (only available since PHP 4.2.0, "double" used in older versions is now deprecated)
"string"
"array"
"object"
"null" (since PHP 4.2.0)
Returns TRUE if the setting is successful and FALSE if it fails.
The output is:
string(4) "5bar"bool(true)int(5)string(1) "1"