Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP settype() Function

PHP settype() Function

PHP Available FunctionsAvailable PHP Functions

settype() The function is used to set the type of a variable.

PHP version requirement: PHP 4, PHP 5, PHP 7

Syntax


bool settype ( mixed &$var , string $type )

Parameter Description:

- "boolean" (or "bool", since PHP 4.2.0) - "integer" (or "int", since PHP 4.2.0) - "float" (only available after PHP 4.2.0; the "double" used in older versions is now deprecated) - "string" - "array" - "object" - "null" (since PHP 4.2.0)

Return Value

Returns TRUE on success, FALSE on failure.

Example

Example

The output is:


string(4) "5bar"
bool(true)
int(5)
string(1) "1"

PHP Available FunctionsAvailable PHP Functions