PHP settype() Function
PHP settype() Function
The settype() function in PHP is used to set the type of variable var to type.
Syntax
settype ( mixed &$var , string $type )
Parameter
var(required)- This parameter represents the variable being converted.
type(required)- This parameter represents the type of variable that is needed.
The possible values of type are as follows:
- bool or boolean
- int or integer
- double or float
- string
- array
- object
- null
Return
This function returns a Boolean value TRUE on success or returns FALSE on failure.
Example 1
Output
String Variable: 5bar After the settype() function... Integer Variable: 5
Example 2
Output
Boolean Variable: 1 After the settype() function... String Variable: 1
Example 3
Output
Float Variable: 1.987 After the settype() function... Integer Variable: 1
