settype
settype
settype
- It set the type of a variable
Syntax:
bool settype ( mixed var, string type)
- It returns TRUE if successful; otherwise returns FALSE.
Some of the possibles values of type are:
“boolean”
“integer”
“float”
“string”
“array”
“object”
“null”
Example:
$test1 = “5bar”; // string
$test2 = true; // boolean
settype($test1, “integer”);
here the value of $test1 “5bar” (string) is converted to 5 (integer).
settype($test2, “string”);
here the value of $test2 “true” (boolean) is converted to “1″ (string).
