SETTYPE(3) 1 SETTYPE(3)
settype - Set the type of a variable
SYNOPSIS
bool settype (mixed &$var, string $type)
DESCRIPTION
Set the type of variable $var to $type.
PARAMETERS
o $var
- The variable being converted.
o $type
- Possibles values of $type are:
o "boolean" (or, since PHP 4.2.0, "bool")
o "integer" (or, since PHP 4.2.0, "int")
o "float" (only possible since PHP 4.2.0, for older versions use the deprecated variant "double")
o "string"
o "array"
o "object"
o "null" (since PHP 4.2.0)
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
settype(3) example
<?php
$foo = "5bar"; // string
$bar = true; // boolean
settype($foo, "integer"); // $foo is now 5 (integer)
settype($bar, "string"); // $bar is now "1" (string)
?>
NOTES
Note
Maximum value for "int" is PHP_INT_MAX.
SEE ALSO
gettype(3), type-casting, type-juggling.
PHP Documentation Group SETTYPE(3)